Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3421017
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3421017
Commits
40b2b072
Commit
40b2b072
authored
8 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2481637
by Jelle_S, attiks, mdrummond, Wim Leers: Use src in fallback image
parent
b09f9222
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/responsive_image/responsive_image.module
+7
-11
7 additions, 11 deletions
core/modules/responsive_image/responsive_image.module
core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
+1
-5
1 addition, 5 deletions
...nsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
with
8 additions
and
16 deletions
core/modules/responsive_image/responsive_image.module
+
7
−
11
View file @
40b2b072
...
@@ -197,17 +197,13 @@ function template_preprocess_responsive_image(&$variables) {
...
@@ -197,17 +197,13 @@ function template_preprocess_responsive_image(&$variables) {
}
}
else
{
else
{
$variables
[
'output_image_tag'
]
=
FALSE
;
$variables
[
'output_image_tag'
]
=
FALSE
;
// Prepare the fallback image.
Use srcset in the fallback image to avoid
// Prepare the fallback image.
We use the src attribute, which might cause
//
unnecessary preloading of images in older browsers. See
//
double downloads in browsers that don't support the picture tag (might,
//
http://scottjehl.github.io/picturefill/#using-picture and
//
because when picturefill kicks in, it cancels the download and triggers
//
http://scottjehl.github.io/picturefill/#gotchas for more information
.
//
the download for the correct image)
.
$variables
[
'img_element'
]
=
array
(
$variables
[
'img_element'
]
=
array
(
'#theme'
=>
'image'
,
'#theme'
=>
'image'
,
'#srcset'
=>
array
(
'#uri'
=>
_responsive_image_image_style_url
(
$responsive_image_style
->
getFallbackImageStyle
(),
$image
->
getSource
()),
array
(
'uri'
=>
_responsive_image_image_style_url
(
$responsive_image_style
->
getFallbackImageStyle
(),
$image
->
getSource
()),
),
),
);
);
}
}
...
@@ -265,7 +261,7 @@ function template_preprocess_responsive_image(&$variables) {
...
@@ -265,7 +261,7 @@ function template_preprocess_responsive_image(&$variables) {
* <picture>
* <picture>
* <source media="(min-width: 0px)" srcset="sites/default/files/styles/thumbnail/image.jpeg" />
* <source media="(min-width: 0px)" srcset="sites/default/files/styles/thumbnail/image.jpeg" />
* <source media="(min-width: 560px)" sizes="(min-width: 700px) 700px, 100vw" srcset="sites/default/files/styles/large/image.jpeg 480w, sites/default/files/styles/medium/image.jpeg 220w" />
* <source media="(min-width: 560px)" sizes="(min-width: 700px) 700px, 100vw" srcset="sites/default/files/styles/large/image.jpeg 480w, sites/default/files/styles/medium/image.jpeg 220w" />
* <img src
set
="fallback.jpeg" />
* <img src="fallback.jpeg" />
* </picture>
* </picture>
* @endcode
* @endcode
*
*
...
@@ -294,7 +290,7 @@ function template_preprocess_responsive_image(&$variables) {
...
@@ -294,7 +290,7 @@ function template_preprocess_responsive_image(&$variables) {
* <picture>
* <picture>
* <source [...] mime-type="image/webp" srcset="image1.webp 1x, image2.webp 2x, image3.webp 3x"/>
* <source [...] mime-type="image/webp" srcset="image1.webp 1x, image2.webp 2x, image3.webp 3x"/>
* <source [...] mime-type="image/jpeg" srcset="image1.jpeg 1x, image2.jpeg 2x, image3.jpeg 3x"/>
* <source [...] mime-type="image/jpeg" srcset="image1.jpeg 1x, image2.jpeg 2x, image3.jpeg 3x"/>
* <img src
set
="fallback.jpeg" />
* <img src="fallback.jpeg" />
* </picture>
* </picture>
* @endcode
* @endcode
* This way a browser can decide which <source> tag is preferred based on the
* This way a browser can decide which <source> tag is preferred based on the
...
...
This diff is collapsed.
Click to expand it.
core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php
+
1
−
5
View file @
40b2b072
...
@@ -315,11 +315,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
...
@@ -315,11 +315,7 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
$fallback_image
=
array
(
$fallback_image
=
array
(
'#theme'
=>
'image'
,
'#theme'
=>
'image'
,
'#alt'
=>
$alt
,
'#alt'
=>
$alt
,
'#srcset'
=>
array
(
'#uri'
=>
file_url_transform_relative
(
$large_style
->
buildUrl
(
$image
->
getSource
())),
array
(
'uri'
=>
file_url_transform_relative
(
$large_style
->
buildUrl
(
$image
->
getSource
())),
),
),
);
);
// The image.html.twig template has a newline after the <img> tag but
// The image.html.twig template has a newline after the <img> tag but
// responsive-image.html.twig doesn't have one after the fallback image, so
// responsive-image.html.twig doesn't have one after the fallback image, so
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment