-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Omit srcset and sizes if imageSource is non-scalable
- Loading branch information
1 parent
dab3160
commit 95244e5
Showing
2 changed files
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,16 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { | |
srcset = '320w, 400ww, 600w, 800w, 1000w, 1200w, 1600' | ||
sizes = '(max-width: 320px) 280px, (max-width: 480px) 440px, 800px' | ||
} | ||
|
||
nonScalabelSource { | ||
imageSource = Sitegeist.Kaleidoscope:UriImageSource { | ||
uri = "https://dummyimage.com/600x400/000/fff" | ||
alt = 'Alternate assigned to source' | ||
title = 'Title assigned to source' | ||
} | ||
srcset = '320w, 400ww, 600w, 800w, 1000w, 1200w, 1600' | ||
sizes = '(max-width: 320px) 280px, (max-width: 480px) 440px, 800px' | ||
} | ||
} | ||
} | ||
|
||
|
@@ -119,6 +129,7 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { | |
|
||
renderer = Neos.Fusion:Component { | ||
@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} | ||
isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} | ||
|
||
# apply format, width and height to the imageSource | ||
imageSource = ${props.imageSource} | ||
|
@@ -139,8 +150,9 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { | |
<img | ||
src={props.imageSource.src()} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
srcset.@if.has={props.srcset} | ||
srcset.@if.isScalable={props.isScalableSource && props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={props.isScalableSource && props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
loading={props.loading} | ||
class={props.class} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { | |
} | ||
|
||
@if.hasImageSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} | ||
isScalableSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} | ||
|
||
imageSource = ${imageSource} | ||
[email protected] = ${width ? value.withWidth(width) : value} | ||
|
@@ -41,8 +42,9 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { | |
renderer = afx` | ||
<source @if.has={props.imageSource} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
srcset.@if.has={props.srcset} | ||
srcset.@if.isScalable={props.srcset && props.isScalableSource} | ||
sizes={props.sizes} | ||
[email protected]={props.sizes && props.isScalableSource} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
type={props.type} | ||
media={props.media} | ||
|