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.
*
* {@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;
}
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}
*/
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.
*