diff -u b/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php
--- b/core/modules/editor/src/Form/EditorImageDialog.php
+++ b/core/modules/editor/src/Form/EditorImageDialog.php
@@ -209,8 +209,8 @@
// Transform absolute image URLs to relative image URLs: prevent problems
// on multisite set-ups and prevent mixed content errors.
$file_url = file_url_transform_relative($file_url);
- if (!$form_state->getValue(['attributes', 'src'])) {
- $form_state->setValue(['attributes', 'src'], $file_url);
+ if (!$form_state->getValue(array('attributes', 'src'))) {
+ $form_state->setValue(array('attributes', 'src'), $file_url);
}
$form_state->setValue(array('attributes', 'data-entity-uuid'), $file->uuid());
$form_state->setValue(array('attributes', 'data-entity-type'), 'file');
diff -u b/core/modules/image/image.install b/core/modules/image/image.install
--- b/core/modules/image/image.install
+++ b/core/modules/image/image.install
@@ -73,7 +73,7 @@
continue;
}
$allowed_html = $config->get('filters.filter_html.settings.allowed_html');
- $matches = [];
+ $matches = array();
if (!empty($allowed_html) && preg_match('/]*)>/', $allowed_html, $matches)) {
$new_attributes = array_filter(explode(' ', $matches[1]));
$new_attributes[] = 'data-image-style';
diff -u b/core/modules/image/image.module b/core/modules/image/image.module
--- b/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -5,19 +5,12 @@
* Exposes global functionality for creating image styles.
*/
-use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityInterface;
-use Drupal\filter\Entity\FilterFormat;
-use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Image\ImageInterface;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\file\Entity\File;
-use Drupal\file\FileInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\field\FieldConfigInterface;
use Drupal\image\Entity\ImageStyle;
-use Drupal\image\ImageStyleInterface;
/**
* Image style constant for user presets in the database.
@@ -68,20 +61,20 @@
function image_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.image':
- $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#';
+ $field_ui_url = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#';
$output = '';
$output .= '
' . t('About') . '
';
- $output .= '
' . t('The Image module allows you to create fields that contain image files and to configure Image styles that can be used to manipulate the display of images. See the Field module help and the Field UI help pages for terminology and general information on entities, fields, and how to create and manage fields. For more information, see the online documentation for the Image module.', [':image_styles' => \Drupal::url('entity.image_style.collection'), ':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => $field_ui_url, ':image_documentation' => 'https://www.drupal.org/documentation/modules/image']) . '
';
+ $output .= '
' . t('The Image module allows you to create fields that contain image files and to configure Image styles that can be used to manipulate the display of images. See the Field module help and the Field UI help pages for terminology and general information on entities, fields, and how to create and manage fields. For more information, see the online documentation for the Image module.', array(':image_styles' => \Drupal::url('entity.image_style.collection'), ':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => $field_ui_url, ':image_documentation' => 'https://www.drupal.org/documentation/modules/image')) . '
';
$output .= '
' . t('Uses') . '
';
$output .= '
' . t('Defining image styles') . '
';
- $output .= '
' . t('The concept of image styles is that you can upload a single image but display it in several ways; each display variation, or image style, is the result of applying one or more effects to the original image. As an example, you might upload a high-resolution image with a 4:3 aspect ratio, and display it scaled down, square cropped, or black-and-white (or any combination of these effects). The Image module provides a way to do this efficiently: you configure an image style with the desired effects on the Image styles page, and the first time a particular image is requested in that style, the effects are applied. The resulting image is saved, and the next time that same style is requested, the saved image is retrieved without the need to recalculate the effects. Drupal core provides several effects that you can use to define styles; others may be provided by contributed modules.', [':image' => \Drupal::url('entity.image_style.collection')]);
+ $output .= '
' . t('The concept of image styles is that you can upload a single image but display it in several ways; each display variation, or image style, is the result of applying one or more effects to the original image. As an example, you might upload a high-resolution image with a 4:3 aspect ratio, and display it scaled down, square cropped, or black-and-white (or any combination of these effects). The Image module provides a way to do this efficiently: you configure an image style with the desired effects on the Image styles page, and the first time a particular image is requested in that style, the effects are applied. The resulting image is saved, and the next time that same style is requested, the saved image is retrieved without the need to recalculate the effects. Drupal core provides several effects that you can use to define styles; others may be provided by contributed modules.', array(':image' => \Drupal::url('entity.image_style.collection')));
$output .= '
' . t('Naming image styles') . '
';
$output .= '
' . t('When you define an image style, you will need to choose a displayed name and a machine name. The displayed name is shown in administrative pages, and the machine name is used to generate the URL for accessing an image processed in that style. There are two common approaches to naming image styles: either based on the effects being applied (for example, Square 85x85), or based on where you plan to use it (for example, Profile picture).') . '
';
$output .= '
' . t('Configuring image fields') . '
';
$output .= '
' . t('A few of the settings for image fields are defined once when you create the field and cannot be changed later; these include the choice of public or private file storage and the number of images that can be stored in the field. The rest of the settings can be edited later; these settings include the field label, help text, allowed file extensions, image resolution restrictions, and the subdirectory in the public or private file storage where the images will be stored. The editable settings can also have different values for different entity sub-types; for instance, if your image field is used on both Page and Article content types, you can store the files in a different subdirectory for the two content types.') . '
';
$output .= '
' . t('For accessibility and search engine optimization, all images that convey meaning on web sites should have alternate text. Drupal also allows entry of title text for images, but it can lead to confusion for screen reader users and its use is not recommended. Image fields can be configured so that alternate and title text fields are enabled or disabled; if enabled, the fields can be set to be required. The recommended setting is to enable and require alternate text and disable title text.') . '
';
- $output .= '
' . t('When you create an image field, you will need to choose whether the uploaded images will be stored in the public or private file directory defined in your settings.php file and shown on the File system page. This choice cannot be changed later. You can also configure your field to store files in a subdirectory of the public or private directory; this setting can be changed later and can be different for each entity sub-type using the field. For more information on file storage, see the System module help page.', [':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', ['name' => 'system'])]) . '
';
+ $output .= '
' . t('When you create an image field, you will need to choose whether the uploaded images will be stored in the public or private file directory defined in your settings.php file and shown on the File system page. This choice cannot be changed later. You can also configure your field to store files in a subdirectory of the public or private directory; this setting can be changed later and can be different for each entity sub-type using the field. For more information on file storage, see the System module help page.', array(':file-system' => \Drupal::url('system.file_system_settings'), ':system-help' => \Drupal::url('help.page', array('name' => 'system')))) . '
';
$output .= '
' . t('The maximum file size that can be uploaded is limited by PHP settings of the server, but you can restrict it further by configuring a Maximum upload size in the field settings (this setting can be changed later). The maximum file size, either from PHP server settings or field configuration, is automatically displayed to users in the help text of the image field.') . '
';
$output .= '
' . t('You can also configure a minimum and/or maximum resolution for uploaded images. Images that are too small will be rejected. Images that are to large will be resized. During the resizing the EXIF data in the image will be lost.') . '
';
$output .= '
' . t('You can also configure a default image that will be used if no image is uploaded in an image field. This default can be defined for all instances of the field in the field storage settings when you create a field, and the setting can be overridden for each entity sub-type that uses the field.') . '
';
@@ -108,9 +101,9 @@
* Implements hook_theme().
*/
function image_theme() {
- return [
+ return array(
// Theme functions in image.module.
- 'image_style' => [
+ 'image_style' => array(
// HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft
// allows the alt attribute to be omitted in some cases. Therefore,
// default the alt attribute to an empty string, but allow code using
@@ -123,49 +116,49 @@
// - http://dev.w3.org/html5/spec/Overview.html#alt
// The title attribute is optional in all cases, so it is omitted by
// default.
- 'variables' => [
+ 'variables' => array(
'style_name' => NULL,
'uri' => NULL,
'width' => NULL,
'height' => NULL,
'alt' => '',
'title' => NULL,
- 'attributes' => [],
- ],
- ],
+ 'attributes' => array(),
+ ),
+ ),
// Theme functions in image.admin.inc.
- 'image_style_preview' => [
- 'variables' => ['style' => NULL],
+ 'image_style_preview' => array(
+ 'variables' => array('style' => NULL),
'file' => 'image.admin.inc',
- ],
- 'image_anchor' => [
+ ),
+ 'image_anchor' => array(
'render element' => 'element',
'file' => 'image.admin.inc',
- ],
- 'image_resize_summary' => [
- 'variables' => ['data' => NULL, 'effect' => []],
- ],
- 'image_scale_summary' => [
- 'variables' => ['data' => NULL, 'effect' => []],
- ],
- 'image_crop_summary' => [
- 'variables' => ['data' => NULL, 'effect' => []],
- ],
- 'image_rotate_summary' => [
- 'variables' => ['data' => NULL, 'effect' => []],
- ],
+ ),
+ 'image_resize_summary' => array(
+ 'variables' => array('data' => NULL, 'effect' => array()),
+ ),
+ 'image_scale_summary' => array(
+ 'variables' => array('data' => NULL, 'effect' => array()),
+ ),
+ 'image_crop_summary' => array(
+ 'variables' => array('data' => NULL, 'effect' => array()),
+ ),
+ 'image_rotate_summary' => array(
+ 'variables' => array('data' => NULL, 'effect' => array()),
+ ),
// Theme functions in image.field.inc.
- 'image_widget' => [
+ 'image_widget' => array(
'render element' => 'element',
'file' => 'image.field.inc',
- ],
- 'image_formatter' => [
- 'variables' => ['item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL],
+ ),
+ 'image_formatter' => array(
+ 'variables' => array('item' => NULL, 'item_attributes' => NULL, 'url' => NULL, 'image_style' => NULL),
'file' => 'image.field.inc',
- ],
- ];
+ ),
+ );
}
/**
@@ -190,17 +183,17 @@
$image = \Drupal::service('image.factory')->get($uri);
if ($image->isValid()) {
// Check the permissions of the original to grant access to this image.
- $headers = \Drupal::moduleHandler()->invokeAll('file_download', [$original_uri]);
+ $headers = \Drupal::moduleHandler()->invokeAll('file_download', array($original_uri));
// Confirm there's at least one module granting access and none denying access.
if (!empty($headers) && !in_array(-1, $headers)) {
- return [
+ return array(
// Send headers describing the image's size, and MIME-type.
'Content-Type' => $image->getMimeType(),
'Content-Length' => $image->getFileSize(),
// By not explicitly setting them here, this uses normal Drupal
// Expires, Cache-Control and ETag headers to prevent proxy or
// browser caching of private images.
- ];
+ );
}
}
return -1;
@@ -246,14 +239,10 @@
*/
function image_style_options($include_empty = TRUE) {
$styles = ImageStyle::loadMultiple();
- $options = [];
+ $options = array();
if ($include_empty && !empty($styles)) {
$options[''] = t('- None -');
}
- /**
- * @var string $name
- * @var \Drupal\image\ImageStyleInterface $style
- */
foreach ($styles as $name => $style) {
$options[$name] = $style->label();
}
@@ -294,21 +283,21 @@
$style = ImageStyle::load($variables['style_name']);
// Determine the dimensions of the styled image.
- $dimensions = [
+ $dimensions = array(
'width' => $variables['width'],
'height' => $variables['height'],
- ];
+ );
$style->transformDimensions($dimensions, $variables['uri']);
- $variables['image'] = [
+ $variables['image'] = array(
'#theme' => 'image',
'#width' => $dimensions['width'],
'#height' => $dimensions['height'],
'#attributes' => $variables['attributes'],
'#uri' => $style->buildUrl($variables['uri']),
'#style_name' => $variables['style_name'],
- ];
+ );
if (isset($variables['alt']) || array_key_exists('alt', $variables)) {
$variables['image']['#alt'] = $variables['alt'];
@@ -535,49 +524,49 @@
$image_style_options = image_style_options(FALSE);
// Create a form item for image style selection.
- $form['image_style'] = [
+ $form['image_style'] = array(
'#type' => 'item',
'#field_prefix' => '
',
'#field_suffix' => '
',
- ];
+ );
// Add a select element to choose an image style.
- $form['image_style']['selection'] = [
+ $form['image_style']['selection'] = array(
'#title' => t('Image style'),
'#type' => 'select',
'#default_value' => isset($image_element['data-image-style']) ? $image_element['data-image-style'] : array_keys($image_style_options)[0],
'#options' => $image_style_options,
'#required' => TRUE,
- '#wrapper_attributes' => ['class' => ['container-inline']],
- '#attributes' => ['class' => ['container-inline']],
- '#parents' =>['attributes', 'data-image-style'],
- ];
+ '#wrapper_attributes' => array('class' => array('container-inline')),
+ '#attributes' => array('class' => array('container-inline')),
+ '#parents' =>array('attributes', 'data-image-style'),
+ );
// Add a checkbox to toggle preview of the image style.
- $form['image_style']['preview_toggle'] = [
+ $form['image_style']['preview_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Show preview'),
- ];
+ );
// Create a set of image style previews that display if toggled on.
$image_styles = ImageStyle::loadMultiple();
/** @var \Drupal\image\ImageStyleInterface $image_style */
foreach ($image_styles as $image_style_id => $image_style) {
- $preview_arguments = [
+ $preview_arguments = array(
'#theme' => 'image_style_preview',
'#style' => $image_style,
- ];
- $form['image_style']['preview_' . $image_style_id] = [
+ );
+ $form['image_style']['preview_' . $image_style_id] = array(
'#type' => 'fieldset',
- '#title' => t('Preview of %image-style image style', ['%image-style' => $image_style->label()]),
+ '#title' => t('Preview of %image-style image style', array('%image-style' => $image_style->label())),
'#markup' => \Drupal::service('renderer')->render($preview_arguments),
- '#states' => [
+ '#states' => array(
'visible' => [
- ':input[name="image_style[preview_toggle]"]' => ['checked' => TRUE],
- ':input[name="attributes[data-image-style]"]' => ['value' => $image_style_id],
+ ':input[name="image_style[preview_toggle]"]' => array('checked' => TRUE),
+ ':input[name="attributes[data-image-style]"]' => array('value' => $image_style_id),
],
- ],
- ];
+ ),
+ );
}
// Attach the image admin library.
@@ -622,10 +611,10 @@
if ($image->isValid()) {
// Get the original width and height of the image.
- $dimensions = [
+ $dimensions = array(
'width' => $image->getWidth(),
'height' => $image->getHeight()
- ];
+ );
// Transform the 'width' and 'height' dimensions of the image based on the
// image style.
reverted:
--- b/core/modules/responsive_image/js/plugins/drupalresponsiveimagestyle/plugin.js
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * @file
- * Drupal Responsive Image Style plugin.
- *
- * This alters the existing CKEditor image2 widget plugin, which is already
- * altered by the Drupal Image plugin, to data-responsive-image-style attribute
- * to be set.
- *
- * @ignore
- */
-
-(function (CKEDITOR) {
-
- 'use strict';
-
- CKEDITOR.plugins.add('drupalresponsiveimagestyle', {
- requires: 'drupalimage',
-
- beforeInit: function (editor) {
- // Override the image2 widget definition to handle the additional
- // data-responsive-image-style attributes.
- editor.on('widgetDefinition', function (event) {
- var widgetDefinition = event.data;
- if (widgetDefinition.name !== 'image') {
- return;
- }
- // Override default features definitions for drupalresponsiveimagestyle.
- CKEDITOR.tools.extend(widgetDefinition.features, {
- responsiveimage: {
- requiredContent: 'img[data-responsive-image-style]'
- }
- }, true);
-
- // Override requiredContent & allowedContent.
- var requiredContent = widgetDefinition.requiredContent.getDefinition();
- requiredContent.attributes['data-responsive-image-style'] = '';
- widgetDefinition.requiredContent = new CKEDITOR.style(requiredContent);
- widgetDefinition.allowedContent.img.attributes += ',!data-responsive-image-style';
-
- // Override downcast().
- var originalDowncast = widgetDefinition.downcast;
- widgetDefinition.downcast = function (element) {
- var img = originalDowncast.call(this, element);
- if (!img) {
- img = findElementByName(element, 'img');
- }
- img.attributes['data-responsive-image-style'] = this.data['data-responsive-image-style'];
- return img;
- };
-
- // Override upcast().
- var originalUpcast = widgetDefinition.upcast;
- widgetDefinition.upcast = function (element, data) {
- if (element.name !== 'img' || !element.attributes['data-entity-type'] || !element.attributes['data-entity-uuid']) {
- return;
- }
- // Don't initialize on pasted fake objects.
- else if (element.attributes['data-cke-realelement']) {
- return;
- }
-
- // Parse the data-responsive-image-style attribute.
- data['data-responsive-image-style'] = element.attributes['data-responsive-image-style'];
-
- // Upcast after parsing so correct element attributes are parsed.
- element = originalUpcast.call(this, element, data);
-
- return element;
- };
-
- // Protected; keys of the widget data to be sent to the Drupal dialog.
- // Append to the values defined by the drupalimage plugin.
- // @see core/modules/ckeditor/js/plugins/drupalimage/plugin.js
- CKEDITOR.tools.extend(widgetDefinition._mapDataToDialog, {
- 'data-responsive-image-style': 'data-responsive-image-style'
- });
- // Low priority to ensure drupalimage's event handler runs first.
- }, null, null, 20);
- }
- });
-
- /**
- * Finds an element by its name.
- *
- * Function will check first the passed element itself and then all its
- * children in DFS order.
- *
- * @param {CKEDITOR.htmlParser.element} element
- * The element to search.
- * @param {string} name
- * The element name to search for.
- *
- * @return {?CKEDITOR.htmlParser.element}
- * The found element, or null.
- */
- function findElementByName(element, name) {
- if (element.name === name) {
- return element;
- }
-
- var found = null;
- element.forEach(function (el) {
- if (el.name === name) {
- found = el;
- // Stop here.
- return false;
- }
- }, CKEDITOR.NODE_ELEMENT);
- return found;
- }
-
-})(CKEDITOR);
reverted:
--- b/core/modules/responsive_image/responsive_image.install
+++ /dev/null
@@ -1,27 +0,0 @@
-listAll('filter.format') as $name) {
- $config = $config_factory->getEditable($name);
- if (!$config->get('filters.filter_responsive_image_style.status')) {
- continue;
- }
- $allowed_html = $config->get('filters.filter_html.settings.allowed_html');
- $matches = [];
- if (!empty($allowed_html) && preg_match('/]*)>/', $allowed_html, $matches)) {
- $new_attributes = array_filter(explode(' ', $matches[1]));
- $new_attributes[] = 'data-responsive-image-style';
- $allowed_html = preg_replace('/]*)>/', '', $allowed_html);
- $config->set('filters.filter_html.settings.allowed_html', $allowed_html);
- $config->save();
- }
- }
-}
reverted:
--- b/core/modules/responsive_image/responsive_image.module
+++ a/core/modules/responsive_image/responsive_image.module
@@ -5,20 +5,14 @@
* Responsive image display formatter for image fields.
*/
-use Drupal\Component\Utility\Unicode;
-use Drupal\Core\Form\FormStateInterface;
-use Drupal\Core\Image\ImageInterface;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Logger\RfcLogLevel;
+use Drupal\Component\Utility\Unicode;
-use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Routing\RouteMatchInterface;
-use Drupal\breakpoint\BreakpointInterface;
-use Drupal\filter\Entity\FilterFormat;
-use Drupal\file\Entity\File;
-use Drupal\file\FileInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
+use Drupal\Core\Image\ImageInterface;
+use Drupal\breakpoint\BreakpointInterface;
-use Drupal\responsive_image\ResponsiveImageStyleInterface;
/**
* The machine name for the empty image breakpoint image style option.
@@ -34,26 +28,25 @@
case 'help.page.responsive_image':
$output = '';
$output .= '
' . t('About') . '
';
+ $output .= '
' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the online documentation for the Responsive Image module.', array( ':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image')) . '
';
- $output .= '
' . t('The Responsive Image module provides an image formatter that allows browsers to select which image file to display based on media queries or which image file types the browser supports, using the HTML 5 picture and source elements and/or the sizes, srcset and type attributes. For more information, see the online documentation for the Responsive Image module.', [':responsive_image' => 'https://www.drupal.org/documentation/modules/responsive_image']) . '
';
$output .= '
' . t('Uses') . '
';
$output .= '
';
$output .= '
' . t('Defining responsive image styles') . '
';
+ $output .= '
' . t('By creating responsive image styles you define which options the browser has in selecting which image file to display. In most cases this means providing different image sizes based on the viewport size. On the Responsive image styles page, click Add responsive image style to create a new style. First choose a label, a fallback image style and a breakpoint group and click Save.', array(':responsive_image_style' => \Drupal::url('entity.responsive_image_style.collection'))) . '
';
- $output .= '
' . t('By creating responsive image styles you define which options the browser has in selecting which image file to display. In most cases this means providing different image sizes based on the viewport size. On the Responsive image styles page, click Add responsive image style to create a new style. First choose a label, a fallback image style and a breakpoint group and click Save.', [':responsive_image_style' => \Drupal::url('entity.responsive_image_style.collection')]) . '
';
$output .= '
';
$output .= '
' . t('Fallback image style') . '
';
$output .= '
' . t('The fallback image style is typically the smallest size image you expect to appear in this space. Because the responsive images module uses the Picturefill library so that responsive images can work in older browsers, the fallback image should only appear on a site if an error occurs.)
');
$output .= '
' . t('Breakpoint groups: viewport sizing vs art direction') . '
';
+ $output .= '
' . t('The breakpoint group typically only needs a single breakpoint with an empty media query in order to do viewport sizing. Multiple breakpoints are used for changing the crop or aspect ratio of images at different viewport sizes, which is often referred to as art direction. Once you select a breakpoint group, you can choose which breakpoints to use for the responsive image style. By default, the option do not use this breakpoint is selected for each breakpoint. See the help page of the Breakpoint module for more information.', array(':breakpoint_help' => \Drupal::url('help.page', array('name' => 'breakpoint')))) . '
';
- $output .= '
' . t('The breakpoint group typically only needs a single breakpoint with an empty media query in order to do viewport sizing. Multiple breakpoints are used for changing the crop or aspect ratio of images at different viewport sizes, which is often referred to as art direction. Once you select a breakpoint group, you can choose which breakpoints to use for the responsive image style. By default, the option do not use this breakpoint is selected for each breakpoint. See the help page of the Breakpoint module for more information.', [':breakpoint_help' => \Drupal::url('help.page', ['name' => 'breakpoint'])]) . '
';
$output .= '
' . t('Breakpoint settings: sizes vs image styles') . '
';
$output .= '
' . t('While you have the option to provide only one image style per breakpoint, the sizes option allows you to provide more options to browsers as to which image file it can display, even when using multiple breakpoints for art direction. Breakpoints are defined in the configuration files of the theme.
');
$output .= '
' . t('Sizes field') . '
';
$output .= '
' . t('Once the sizes option is selected, you can let the browser know the size of this image in relation to the site layout, using the Sizes field. For a hero image that always fills the entire screen, you could simply enter 100vw, which means 100% of the viewport width. For an image that fills 90% of the screen for small viewports, but only fills 40% of the screen when the viewport is larger than 40em (typically 640px), you could enter "(min-width: 40em) 40vw, 90vw" in the Sizes field. The last item in the comma-separated list is the smallest viewport size: other items in the comma-separated list should have a media condition paired with an image width. Media conditions are similar to a media query, often a min-width paired with a viewport width using em or px units: e.g. (min-width: 640px) or (min-width: 40em). This is paired with the image width at that viewport size using px, em or vw units. The vw unit is viewport width and is used instead of a percentage because the percentage always refers to the width of the entire viewport.
');
$output .= '
' . t('Image styles for sizes') . '
';
+ $output .= '
' . t('Below the Sizes field you can choose multiple image styles so the browser can choose the best image file size to fill the space defined in the Sizes field. Typically you will want to use image styles that resize your image to have options that range from the smallest px width possible for the space the image will appear in to the largest px width possible, with a variety of widths in between. You may want to provide image styles with widths that are 1.5x to 2x the space available in the layout to account for high resolution screens. Image styles can be defined on the Image styles page that is provided by the Image module.', array(':image_styles' => \Drupal::url('entity.image_style.collection'), ':image_help' => \Drupal::url('help.page', array('name' => 'image')))) . '
';
- $output .= '
' . t('Below the Sizes field you can choose multiple image styles so the browser can choose the best image file size to fill the space defined in the Sizes field. Typically you will want to use image styles that resize your image to have options that range from the smallest px width possible for the space the image will appear in to the largest px width possible, with a variety of widths in between. You may want to provide image styles with widths that are 1.5x to 2x the space available in the layout to account for high resolution screens. Image styles can be defined on the Image styles page that is provided by the Image module.', [':image_styles' => \Drupal::url('entity.image_style.collection'), ':image_help' => \Drupal::url('help.page', ['name' => 'image'])]) . '
' . t('After defining responsive image styles, you can use them in the display settings for your Image fields, so that the site displays responsive images using the HTML5 picture tag. Open the Manage display page for the entity type (content type, taxonomy vocabulary, etc.) that the Image field is attached to. Choose the format Responsive image, click the Edit icon, and select one of the responsive image styles that you have created. For general information on how to manage fields and their display see the Field UI module help page. For background information about entities and fields see the Field module help page.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':field_help' => \Drupal::url('help.page', array('name' => 'field')))) . '
';
- $output .= '
' . t('After defining responsive image styles, you can use them in the display settings for your Image fields, so that the site displays responsive images using the HTML5 picture tag. Open the Manage display page for the entity type (content type, taxonomy vocabulary, etc.) that the Image field is attached to. Choose the format Responsive image, click the Edit icon, and select one of the responsive image styles that you have created. For general information on how to manage fields and their display see the Field UI module help page. For background information about entities and fields see the Field module help page.', [
- ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':field_help' => \Drupal::url('help.page', ['name' => 'field'])]) . '