From 4e1287e693b4223a8272074a240f4a54d825f318 Mon Sep 17 00:00:00 2001 From: webchick Date: Sun, 4 Nov 2012 14:44:43 -0800 Subject: [PATCH] Issue #1775530 follow-up by attiks: Minor tweaks to picture module. --- core/modules/breakpoint/breakpoint.info | 1 - .../picture/PictureMappingFormController.php | 7 +++--- .../picture/PictureMappingListController.php | 3 +-- .../Plugin/Core/Entity/PictureMapping.php | 8 +++---- .../field/formatter/PictureFormatter.php | 9 ++++--- core/modules/picture/picture.info | 3 +-- core/modules/picture/picture.module | 24 +++++++++---------- .../picture/picturefill/picturefill.js | 2 +- 8 files changed, 26 insertions(+), 31 deletions(-) diff --git a/core/modules/breakpoint/breakpoint.info b/core/modules/breakpoint/breakpoint.info index fee160f974f..793bdcdcfdf 100644 --- a/core/modules/breakpoint/breakpoint.info +++ b/core/modules/breakpoint/breakpoint.info @@ -4,4 +4,3 @@ package = Core version = VERSION core = 8.x -dependencies[] = config diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php index 3feaf5d8b30..466e14c8536 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php @@ -2,14 +2,13 @@ /** * @file - * Definition of Drupal\picture\PictureFormController. + * Contains Drupal\picture\PictureFormController. */ namespace Drupal\picture; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityFormController; -use Drupal\picture\PictureMapping; /** * Form controller for the picture edit/add forms. @@ -49,14 +48,14 @@ class PictureMappingFormController extends EntityFormController { ); if ((bool) $picture_mapping->id() && $this->operation != 'duplicate') { - $description = t('Select a breakpoint group from the enabled themes.') . ' ' . t("Warning: if you change the breakpoint group you lose all you're selected mappings."); + $description = t('Select a breakpoint group from the enabled themes.') . ' ' . t("Warning: if you change the breakpoint group you lose all your selected mappings."); } else { $description = t('Select a breakpoint group from the enabled themes.'); } $form['breakpointGroup'] = array( '#type' => 'select', - '#title' => t('Breakpoint Group'), + '#title' => t('Breakpoint group'), '#default_value' => !empty($picture_mapping->breakpointGroup) ? $picture_mapping->breakpointGroup->id() : '', '#options' => breakpoint_group_select_options(), '#required' => TRUE, diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php index f63127dc983..343dbd3ddf3 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingListController.php @@ -2,14 +2,13 @@ /** * @file - * Definition of Drupal\picture\PictureListController. + * Contains Drupal\picture\PictureListController. */ namespace Drupal\picture; use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityInterface; -use Drupal\picture\PictureMapping; /** * Provides a listing of Pictures. diff --git a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php index b44d8bfaf60..27103032c87 100644 --- a/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php +++ b/core/modules/picture/lib/Drupal/picture/Plugin/Core/Entity/PictureMapping.php @@ -13,7 +13,7 @@ use Drupal\Core\Annotation\Translation; /** * Defines the Picture entity. - * + * * @Plugin( * id = "picture_mapping", * label = @Translation("Picture mapping"), @@ -106,7 +106,7 @@ class PictureMapping extends ConfigEntityBase { } /** - * Load breakpoint group. + * Loads the breakpoint group. */ protected function loadBreakpointGroup() { if ($this->breakpointGroup) { @@ -116,7 +116,7 @@ class PictureMapping extends ConfigEntityBase { } /** - * Load all mappings, remove non-existing ones. + * Loads all mappings and removes non-existing ones. */ protected function loadAllMappings() { $loaded_mappings = $this->mappings; @@ -145,7 +145,7 @@ class PictureMapping extends ConfigEntityBase { } /** - * Check if there's at least one mapping defined. + * Checks if there's at least one mapping defined. */ public function hasMappings() { $mapping_found = FALSE; diff --git a/core/modules/picture/lib/Drupal/picture/Plugin/field/formatter/PictureFormatter.php b/core/modules/picture/lib/Drupal/picture/Plugin/field/formatter/PictureFormatter.php index a4e83989c91..b371d488953 100644 --- a/core/modules/picture/lib/Drupal/picture/Plugin/field/formatter/PictureFormatter.php +++ b/core/modules/picture/lib/Drupal/picture/Plugin/field/formatter/PictureFormatter.php @@ -106,7 +106,7 @@ class PictureFormatter extends FormatterBase { } } else { - $summary[] = t('Please select a picture mapping'); + $summary[] = t('Select a picture mapping.'); } return implode('
', $summary); @@ -137,13 +137,12 @@ class PictureFormatter extends FormatterBase { // @todo add the following when breakpoint->status is added again: // $picture_mapping->breakpointGroup->breakpoints[$breakpoint_name]->status if (isset($picture_mapping->breakpointGroup->breakpoints[$breakpoint_name])) { - $breakpoint = $picture_mapping->breakpointGroup->breakpoints[$breakpoint_name]; + $breakpoint = $picture_mapping->breakpointGroup->breakpoints[$breakpoint_name]; - // Determine the enabled multipliers. - $multipliers = array_intersect_key($multipliers, $breakpoint->multipliers); + // Determine the enabled multipliers. + $multipliers = array_intersect_key($multipliers, $breakpoint->multipliers); foreach ($multipliers as $multiplier => $image_style) { // Make sure the multiplier still exists. - //if (!empty(array_intersect($multiplier, $breakpoint->multipliers))) { if (!empty($image_style)) { // First mapping found is used as fallback. if (empty($fallback_image_style)) { diff --git a/core/modules/picture/picture.info b/core/modules/picture/picture.info index 3113a7ff93b..47649d5c14e 100644 --- a/core/modules/picture/picture.info +++ b/core/modules/picture/picture.info @@ -1,9 +1,8 @@ name = Picture -description = Picture element +description = Provides an image formatter and breakpoint mappings to output responsive images using the HTML5 picture tag. package = Core version = VERSION core = 8.x dependencies[] = breakpoint -dependencies[] = config dependencies[] = image configure = admin/config/media/picturemapping diff --git a/core/modules/picture/picture.module b/core/modules/picture/picture.module index 5d77db64d9f..e5a66dd272b 100644 --- a/core/modules/picture/picture.module +++ b/core/modules/picture/picture.module @@ -16,20 +16,20 @@ function picture_help($path, $arg) { switch ($path) { case 'admin/help#picture': $output .= '

' . t('About') . '

'; - $output .= '

' . t('The picture module allows you to output responsive images using the new HTML5 picture tag.', array( - '@link' => 'http://responsiveimages.org/', - )) . '

'; + $output .= '

' . t('The Picture module provides an image formatter and breakpoint mappings to output responsive images using the HTML5 picture tag.') . '

'; + $output .= '

' . t('Uses') . '

'; + $output .= '
'; + $output .= '
' . t('Mapping image styles to breakpoints') . '
'; + $output .= '
' . t('To use responsive images, you need to define what size the images should be depending on the breakpoints. The Picture module allows you to define which image style should be used for each breakpoint on the picture mappings administrative page.', array( + '@link' => url('admin/config/media/picturemapping'), + )) . '
'; + $output .= '
' . t('Formatting an Image field') . '
'; + $output .= '
' . t('Images in Image fields can be formatted using the Picture formatter, to make them responsive. They will be automatically resized depending on breakpoints.') . '
'; + $output .= '
'; break; case 'admin/config/media/picturemapping': $output .= '

' . t('A picture mapping associates an image style with each breakpoint defined by your theme.') . '

'; break; - case 'admin/config/media/picturemapping/add': - $output .= '

' . t('Create a new picture mapping by specifying a name and selecting a breakpoint group.') . '

'; - break; - case 'admin/config/media/picturemapping/%/edit': - $output .= '

' . t('For each breakpoint you can select a corresponding image style.') . '

'; - $output .= '

' . t("Warning: if you change the breakpoint group you lose all you're selected mappings.") . '

'; - break; } return $output; @@ -308,12 +308,12 @@ function theme_picture($variables) { } $output[] = ''; - // add source tags to the output. + // Add source tags to the output. foreach ($sources as $source) { $output[] = theme('picture_source', $source); } - // output the fallback image. + // Output the fallback image. $output[] = ''; $output[] = ''; return implode("\n", $output); diff --git a/core/modules/picture/picturefill/picturefill.js b/core/modules/picture/picturefill/picturefill.js index 8e4c2319066..8df8eb91ebd 100644 --- a/core/modules/picture/picturefill/picturefill.js +++ b/core/modules/picture/picturefill/picturefill.js @@ -43,7 +43,7 @@ // See which sources match. for (var j = 0, jl = sources.length; j < jl; j++ ) { var media = sources[j].getAttribute('media'); - // if there's no media specified, OR w.matchMedia is supported + // If there's no media specified or the media query matches, add it. if (!media || (w.matchMedia && w.matchMedia(media).matches)) { matches.push(sources[j]); }