X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fimage%2Fsrc%2FEntity%2FImageStyle.php;h=dd261248a78fe171d5513cc06229a9bcba694635;hp=fb096a7fdb295226b7cd06d7fd7517a96d633ccf;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/image/src/Entity/ImageStyle.php b/web/core/modules/image/src/Entity/ImageStyle.php index fb096a7fd..dd261248a 100644 --- a/web/core/modules/image/src/Entity/ImageStyle.php +++ b/web/core/modules/image/src/Entity/ImageStyle.php @@ -14,9 +14,11 @@ use Drupal\image\ImageEffectInterface; use Drupal\image\ImageStyleInterface; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\UrlHelper; +use Drupal\Component\Utility\Unicode; use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; use Drupal\Core\Entity\Entity\EntityViewDisplay; + /** * Defines an image style configuration entity. * @@ -274,9 +276,8 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity * {@inheritdoc} */ public function createDerivative($original_uri, $derivative_uri) { - // If the source file doesn't exist, return FALSE without creating folders. - $image = \Drupal::service('image.factory')->get($original_uri); + $image = $this->getImageFactory()->get($original_uri); if (!$image->isValid()) { return FALSE; } @@ -340,6 +341,18 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity return $this; } + /** + * {@inheritdoc} + */ + public function supportsUri($uri) { + // Only support the URI if its extension is supported by the current image + // toolkit. + return in_array( + Unicode::strtolower(pathinfo($uri, PATHINFO_EXTENSION)), + $this->getImageFactory()->getSupportedExtensions() + ); + } + /** * {@inheritdoc} */ @@ -408,6 +421,16 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity return \Drupal::service('plugin.manager.image.effect'); } + /** + * Returns the image factory. + * + * @return \Drupal\Core\Image\ImageFactory + * The image factory. + */ + protected function getImageFactory() { + return \Drupal::service('image.factory'); + } + /** * Gets the Drupal private key. *