Issue #1775530 follow-up by attiks: Minor tweaks to picture module.

8.0.x
webchick 2012-11-04 14:44:43 -08:00
parent 00613c9009
commit 4e1287e693
8 changed files with 26 additions and 31 deletions

View File

@ -4,4 +4,3 @@ package = Core
version = VERSION
core = 8.x
dependencies[] = config

View File

@ -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,

View File

@ -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.

View File

@ -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;

View File

@ -106,7 +106,7 @@ class PictureFormatter extends FormatterBase {
}
}
else {
$summary[] = t('Please select a picture mapping');
$summary[] = t('Select a picture mapping.');
}
return implode('<br />', $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)) {

View File

@ -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

View File

@ -16,20 +16,20 @@ function picture_help($path, $arg) {
switch ($path) {
case 'admin/help#picture':
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The picture module allows you to output responsive images using the new <a href="@link">HTML5 picture tag</a>.', array(
'@link' => 'http://responsiveimages.org/',
)) . '</p>';
$output .= '<p>' . t('The Picture module provides an image formatter and breakpoint mappings to output responsive images using the HTML5 picture tag.') . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Mapping image styles to breakpoints') . '</dt>';
$output .= '<dd>' . 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 <a href="@link">picture mappings administrative page</a>.', array(
'@link' => url('admin/config/media/picturemapping'),
)) . '</dd>';
$output .= '<dt>' . t('Formatting an Image field') . '</dt>';
$output .= '<dd>' . t('Images in Image fields can be formatted using the Picture formatter, to make them responsive. They will be automatically resized depending on breakpoints.') . '</dd>';
$output .= '</dl>';
break;
case 'admin/config/media/picturemapping':
$output .= '<p>' . t('A picture mapping associates an image style with each breakpoint defined by your theme.') . '</p>';
break;
case 'admin/config/media/picturemapping/add':
$output .= '<p>' . t('Create a new picture mapping by specifying a name and selecting a breakpoint group.') . '</p>';
break;
case 'admin/config/media/picturemapping/%/edit':
$output .= '<p>' . t('For each breakpoint you can select a corresponding image style.') . '</p>';
$output .= '<p>' . t("Warning: if you change the breakpoint group you lose all you're selected mappings.") . '</p>';
break;
}
return $output;
@ -308,12 +308,12 @@ function theme_picture($variables) {
}
$output[] = '<picture' . new Attribute($attributes) . '>';
// 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[] = '<noscript>' . theme('image_style', $variables) . '</noscript>';
$output[] = '</picture>';
return implode("\n", $output);

View File

@ -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]);
}