Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -1,6 +1,6 @@
|
|||
entity.responsive_image_style.collection:
|
||||
title: 'Responsive image styles'
|
||||
description: 'Manage responsive image styles'
|
||||
description: 'Manage responsive image styles.'
|
||||
weight: 10
|
||||
route_name: entity.responsive_image_style.collection
|
||||
parent: system.admin_config_media
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* Responsive image display formatter for image fields.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use \Drupal\Core\Template\Attribute;
|
||||
|
@ -43,30 +42,6 @@ function responsive_image_help($route_name, RouteMatchInterface $route_match) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function responsive_image_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['admin/config/media/responsive-image-style'] = array(
|
||||
'title' => 'Responsive image styles',
|
||||
'description' => 'Manage responsive image styles',
|
||||
'weight' => 10,
|
||||
'route_name' => 'entity.responsive_image_style.collection',
|
||||
);
|
||||
$items['admin/config/media/responsive-image-style/%responsive_image_style'] = array(
|
||||
'title' => 'Edit responsive image style',
|
||||
'route_name' => 'entity.responsive_image_style.edit_form',
|
||||
);
|
||||
$items['admin/config/media/responsive-image-style/%responsive_image_style/duplicate'] = array(
|
||||
'title' => 'Duplicate responsive image style',
|
||||
'route_name' => 'entity.responsive_image_style.duplicate_form',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
|
@ -157,8 +132,13 @@ function template_preprocess_responsive_image(&$variables) {
|
|||
|
||||
$image = \Drupal::service('image.factory')->get($variables['uri']);
|
||||
$responsive_image_style = ResponsiveImageStyle::load($variables['responsive_image_style_id']);
|
||||
// All breakpoints and multipliers.
|
||||
$breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup());
|
||||
// Retrieve all breakpoints and multipliers and reverse order of breakpoints.
|
||||
// By default, breakpoints are ordered from smallest weight to largest:
|
||||
// the smallest weight is expected to have the smallest breakpoint width,
|
||||
// while the largest weight is expected to have the largest breakpoint
|
||||
// width. For responsive images, we need largest breakpoint widths first, so
|
||||
// we need to reverse the order of these breakpoints.
|
||||
$breakpoints = array_reverse(\Drupal::service('breakpoint.manager')->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
|
||||
foreach ($responsive_image_style->getKeyedImageStyleMappings() as $breakpoint_id => $multipliers) {
|
||||
if (isset($breakpoints[$breakpoint_id])) {
|
||||
$variables['sources'][] = responsive_image_build_source_attributes($image, $variables, $breakpoints[$breakpoint_id], $multipliers);
|
||||
|
@ -352,7 +332,7 @@ function responsive_image_build_source_attributes(ImageInterface $image, array $
|
|||
// this breakpoint should be merged into one srcset and the sizes
|
||||
// attribute should be merged as well.
|
||||
if (is_null($dimensions['width'])) {
|
||||
throw new \LogicException(SafeMarkup::format('Could not determine image width for @file using image style with ID: @image_style_name. This image style can not be used for a responsive image style mapping using the \'sizes\' attribute.', array('@file' => $image->getSource(), '@image_style_name' => $image_style_name)));
|
||||
throw new \LogicException("Could not determine image width for '{$image->getSource()}' using image style with ID: $image_style_name. This image style can not be used for a responsive image style mapping using the 'sizes' attribute.");
|
||||
}
|
||||
// Use the image width as key so we can sort the array later on.
|
||||
// Images within a srcset should be sorted from small to large, since
|
||||
|
|
|
@ -109,7 +109,12 @@ class ResponsiveImageStyleForm extends EntityForm {
|
|||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
$breakpoints = $this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup());
|
||||
// By default, breakpoints are ordered from smallest weight to largest:
|
||||
// the smallest weight is expected to have the smallest breakpoint width,
|
||||
// while the largest weight is expected to have the largest breakpoint
|
||||
// width. For responsive images, we need largest breakpoint widths first, so
|
||||
// we need to reverse the order of these breakpoints.
|
||||
$breakpoints = array_reverse($this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()));
|
||||
foreach ($breakpoints as $breakpoint_id => $breakpoint) {
|
||||
foreach ($breakpoint->getMultipliers() as $multiplier) {
|
||||
$label = $multiplier . ' ' . $breakpoint->getLabel() . ' [' . $breakpoint->getMediaQuery() . ']';
|
||||
|
@ -142,7 +147,8 @@ class ResponsiveImageStyleForm extends EntityForm {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate(array $form, FormStateInterface $form_state) {
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
parent::validateForm($form, $form_state);
|
||||
// Only validate on edit.
|
||||
if ($form_state->hasValue('keyed_styles')) {
|
||||
// Check if another breakpoint group is selected.
|
||||
|
|
Reference in a new issue