-
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.
Merge pull request #27 from mficzel/feature/formatAndDimensionOptions
!!! FEATURE: Add props `renderDimensionAttributes`, `width`, `height`, `loading` and `format` resp. `formats`
- Loading branch information
Showing
4 changed files
with
219 additions
and
82 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
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 |
---|---|---|
|
@@ -45,17 +45,43 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { | |
alt = null | ||
title = null | ||
class = null | ||
loading = null | ||
width = null | ||
height = null | ||
format = null | ||
renderDimensionAttributes = true | ||
|
||
renderer = afx` | ||
<img @if.has={props.imageSource} | ||
src={props.imageSource} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
[email protected]={props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
class={props.class} | ||
alt={props.alt} | ||
title={props.title} | ||
/> | ||
` | ||
renderer = Neos.Fusion:Component { | ||
@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\EelHelpers\\ImageSourceHelperInterface')} | ||
|
||
# apply format, width and height to the imageSource | ||
imageSource = ${props.imageSource} | ||
[email protected] = ${props.width ? value.setWidth(props.width) : value} | ||
[email protected] = ${props.height ? value.setHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.setFormat(props.format) : value} | ||
|
||
srcset = ${props.srcset} | ||
sizes = ${props.sizes} | ||
loading = ${props.loading} | ||
alt = ${props.alt} | ||
title = ${props.title} | ||
class = ${props.class} | ||
renderDimensionAttributes = ${props.renderDimensionAttributes} | ||
|
||
renderer = afx` | ||
<img | ||
src={props.imageSource.src()} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
[email protected]={props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
loading={props.loading} | ||
class={props.class} | ||
alt={props.alt} | ||
title={props.title} | ||
width={props.renderDimensionAttributes ? props.imageSource.currentWidth : null} | ||
height={props.renderDimensionAttributes ? props.imageSource.currentHeight : null} | ||
/> | ||
` | ||
} | ||
} |
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 |
---|---|---|
|
@@ -29,34 +29,85 @@ prototype(Sitegeist.Kaleidoscope:Picture) < prototype(Neos.Fusion:Component) { | |
} | ||
} | ||
|
||
imageSource = Sitegeist.Kaleidoscope:DummyImageSource | ||
imageSource = null | ||
srcset = null | ||
sizes = null | ||
loading = null | ||
sources = null | ||
formats = null | ||
width = null | ||
height = null | ||
alt = null | ||
title = null | ||
class = null | ||
content = '' | ||
renderDimensionAttributes = null | ||
|
||
renderer = afx` | ||
<picture @if.has={props.imageSource} class={props.class}> | ||
{props.content} | ||
<Neos.Fusion:Collection collection={props.sources} itemName="source" @children="itemRenderer" @if.has={props.sources}> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={source.imageSource ? source.imageSource : props.imageSource} | ||
type={source.type} | ||
media={source.media} | ||
srcset={source.srcset ? source.srcset : props.srcset} | ||
sizes={source.sizes ? source.sizes : props.sizes} | ||
# | ||
# put the values that shall be applied to sources automatically to the context | ||
# to make them available to all props during evaluation | ||
# | ||
@context { | ||
__imageSource = ${this.imageSource} | ||
__srcset = ${this.srcset} | ||
__sizes = ${this.sizes} | ||
__width = ${this.width} | ||
__height = ${this.height} | ||
__format = ${this.format} | ||
} | ||
|
||
renderer = Neos.Fusion:Component { | ||
@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\EelHelpers\\ImageSourceHelperInterface')} | ||
|
||
# apply format, width and height to the imageSource | ||
imageSource = ${props.imageSource} | ||
[email protected] = ${props.width ? value.setWidth(props.width) : value} | ||
[email protected] = ${props.height ? value.setHeight(props.height) : value} | ||
[email protected] = ${props.format ? value.setFormat(props.format) : value} | ||
|
||
srcset = ${props.srcset} | ||
sizes = ${props.sizes} | ||
loading = ${props.loading} | ||
sources = ${props.sources} | ||
formats = ${props.formats} | ||
alt = ${props.alt} | ||
title = ${props.title} | ||
class = ${props.class} | ||
content = ${props.content} | ||
renderDimensionAttributes = ${Type.isBoolean(props.renderDimensionAttributes) ? props.renderDimensionAttributes : (!props.content && !props.sources)} | ||
|
||
renderer = afx` | ||
<picture class={props.class}> | ||
{props.content} | ||
<Neos.Fusion:Collection collection={props.sources} itemName="source" @if.has={props.sources}> | ||
<Sitegeist.Kaleidoscope:Source | ||
imageSource={source.imageSource ? source.imageSource : props.imageSource} | ||
type={source.type} | ||
media={source.media} | ||
format={source.format} | ||
width={source.width} | ||
height={source.height} | ||
srcset={source.srcset ? source.srcset : props.srcset} | ||
sizes={source.sizes ? source.sizes : props.sizes} | ||
/> | ||
</Neos.Fusion:Collection> | ||
<Neos.Fusion:Collection | ||
@if.has={props.imageSource && props.formats} | ||
collection={Type.isArray(props.formats) ? props.formats : String.split(props.formats, ',')} | ||
itemName="format" | ||
> | ||
<Sitegeist.Kaleidoscope:Source format={String.trim(format)} /> | ||
</Neos.Fusion:Collection> | ||
<Sitegeist.Kaleidoscope:Image | ||
imageSource={props.imageSource} | ||
sizes={props.sizes} | ||
srcset={props.srcset} | ||
loading={props.loading} | ||
alt={props.alt} | ||
title={props.title} | ||
renderDimensionAttributes={props.renderDimensionAttributes} | ||
/> | ||
</Neos.Fusion:Collection> | ||
<Sitegeist.Kaleidoscope:Image | ||
imageSource={props.imageSource} | ||
sizes={props.sizes} | ||
srcset={props.srcset} | ||
alt={props.alt} | ||
title={props.title} | ||
/> | ||
</picture> | ||
` | ||
</picture> | ||
` | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,19 +5,47 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { | |
} | ||
|
||
imageSource = null | ||
type = null | ||
media = null | ||
srcset = null | ||
sizes = null | ||
width = null | ||
height = null | ||
format = null | ||
type = null | ||
media = null | ||
|
||
renderer = Neos.Fusion:Component { | ||
|
||
renderer = afx` | ||
<source @if.has={props.imageSource} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
[email protected]={props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
type={props.type} | ||
media={props.media} | ||
/> | ||
` | ||
@context { | ||
imageSource = ${props.imageSource || __imageSource} | ||
format = ${props.format || __format} | ||
width = ${props.width || __width} | ||
height = ${props.height || __height} | ||
srcset = ${props.srcset || __srcset} | ||
sizes = ${props.sizes || __sizes} | ||
} | ||
|
||
@if.hasImageSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\EelHelpers\\ImageSourceHelperInterface')} | ||
|
||
imageSource = ${imageSource} | ||
[email protected] = ${width ? value.setWidth(width) : value} | ||
[email protected] = ${height ? value.setHeight(height) : value} | ||
[email protected] = ${format ? value.setFormat(format) : value} | ||
|
||
type = ${format ? 'image/' + format : props.type} | ||
srcset = ${srcset} | ||
sizes = ${srcset} | ||
media = ${props.media} | ||
|
||
renderer = afx` | ||
<source @if.has={props.imageSource} | ||
src={props.imageSource.src()} | ||
srcset={props.imageSource.srcset(props.srcset)} | ||
[email protected]={props.srcset} | ||
sizes={props.sizes} | ||
[email protected]={Type.isArray(value) ? Array.join(value, ', ') : value} | ||
type={props.type} | ||
media={props.media} | ||
/> | ||
` | ||
} | ||
} |