3 namespace Drupal\Driver\Fields\Drupal8;
6 * Image field handler for Drupal 7.
8 class ImageHandler extends AbstractHandler {
13 public function expand($values) {
14 $data = file_get_contents($values[0]);
15 if (FALSE === $data) {
16 throw new \Exception("Error reading file");
19 /* @var \Drupal\file\FileInterface $file */
20 $file = file_save_data(
22 'public://' . uniqid() . '.jpg');
24 if (FALSE === $file) {
25 throw new \Exception("Error saving file");
31 'target_id' => $file->id(),
32 'alt' => 'Behat test image',
33 'title' => 'Behat test image',