X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmedia%2Fsrc%2FPlugin%2Fmedia%2FSource%2FImage.php;h=34b565c05449af1df78e2b31e606816e6e32c43b;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=46f6782c742d0715598731ab283c847ff3410eb6;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/media/src/Plugin/media/Source/Image.php b/web/core/modules/media/src/Plugin/media/Source/Image.php index 46f6782c7..34b565c05 100644 --- a/web/core/modules/media/src/Plugin/media/Source/Image.php +++ b/web/core/modules/media/src/Plugin/media/Source/Image.php @@ -6,7 +6,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; -use Drupal\Core\File\FileSystem; +use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Image\ImageFactory; use Drupal\media\MediaInterface; use Drupal\media\MediaTypeInterface; @@ -22,7 +22,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * label = @Translation("Image"), * description = @Translation("Use local images for reusable media."), * allowed_field_types = {"image"}, - * default_thumbnail_filename = "no-thumbnail.png" + * default_thumbnail_filename = "no-thumbnail.png", + * thumbnail_alt_metadata_attribute = "thumbnail_alt_value" * ) */ class Image extends File { @@ -51,7 +52,7 @@ class Image extends File { /** * The file system service. * - * @var \Drupal\Core\File\FileSystem + * @var \Drupal\Core\File\FileSystemInterface */ protected $fileSystem; @@ -74,10 +75,10 @@ class Image extends File { * The config factory service. * @param \Drupal\Core\Image\ImageFactory $image_factory * The image factory. - * @param \Drupal\Core\File\FileSystem $file_system + * @param \Drupal\Core\File\FileSystemInterface $file_system * The file system service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, ImageFactory $image_factory, FileSystem $file_system) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ConfigFactoryInterface $config_factory, ImageFactory $image_factory, FileSystemInterface $file_system) { parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_type_manager, $entity_field_manager, $field_type_manager, $config_factory); $this->imageFactory = $image_factory; @@ -138,6 +139,9 @@ class Image extends File { case 'thumbnail_uri': return $uri; + + case 'thumbnail_alt_value': + return $media->get($this->configuration['source_field'])->alt ?: parent::getMetadata($media, $name); } return parent::getMetadata($media, $name);