* Image style constant for user presets in the database.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0.
+ *
+ * @see https://www.drupal.org/node/1820974
*/
const IMAGE_STORAGE_NORMAL = 1;
* Image style constant for user presets that override module-defined presets.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0.
+ *
+ * @see https://www.drupal.org/node/1820974
*/
const IMAGE_STORAGE_OVERRIDE = 2;
* Image style constant for module-defined presets in code.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0.
+ *
+ * @see https://www.drupal.org/node/1820974
*/
const IMAGE_STORAGE_DEFAULT = 4;
* Image style constant to represent an editable preset.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0.
+ *
+ * @see https://www.drupal.org/node/1820974
*/
define('IMAGE_STORAGE_EDITABLE', IMAGE_STORAGE_NORMAL | IMAGE_STORAGE_OVERRIDE);
* Image style constant to represent any module-based preset.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0.
+ *
+ * @see https://www.drupal.org/node/1820974
*/
define('IMAGE_STORAGE_MODULE', IMAGE_STORAGE_OVERRIDE | IMAGE_STORAGE_DEFAULT);
'#width' => $dimensions['width'],
'#height' => $dimensions['height'],
'#attributes' => $variables['attributes'],
- '#uri' => $style->buildUrl($variables['uri']),
'#style_name' => $variables['style_name'],
];
+ // If the current image toolkit supports this file type, prepare the URI for
+ // the derivative image. If not, just use the original image resized to the
+ // dimensions specified by the style.
+ if ($style->supportsUri($variables['uri'])) {
+ $variables['image']['#uri'] = $style->buildUrl($variables['uri']);
+ }
+ else {
+ $variables['image']['#uri'] = $variables['uri'];
+ // Don't render the image by default, but allow other preprocess functions
+ // to override that if they need to.
+ $variables['image']['#access'] = FALSE;
+
+ // Inform the site builders why their image didn't work.
+ \Drupal::logger('image')->warning('Could not apply @style image style to @uri because the style does not support it.', [
+ '@style' => $style->label(),
+ '@uri' => $variables['uri'],
+ ]);
+ }
+
if (isset($variables['alt']) || array_key_exists('alt', $variables)) {
$variables['image']['#alt'] = $variables['alt'];
}
if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->getSetting('uri_scheme'))) {
$directory = $field_storage->getSetting('uri_scheme') . '://default_images/';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
- file_move($file_new, $directory . $file_new->filename);
+ file_move($file_new, $directory . $file_new->getFilename());
}
}
if ($file_new && (file_uri_scheme($file_new->getFileUri()) != $field_storage->getSetting('uri_scheme'))) {
$directory = $field_storage->getSetting('uri_scheme') . '://default_images/';
file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
- file_move($file_new, $directory . $file_new->filename);
+ file_move($file_new, $directory . $file_new->getFilename());
}
}