-
-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add image scale property to Teaser Block schema (#4653) #4706
Closed
cihanandac
wants to merge
7
commits into
plone:master
from
cihanandac:Teaser-block-image-resize-#4653
Closed
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6ab2b30
Add image scale property to Teaser Block schema (#4653)
cihanandac afa5d0b
Merge branch 'master' into Teaser-block-image-resize-#4653
erral d87f000
Merge branch 'master' into Teaser-block-image-resize-#4653
erral 2994b29
Add default value to the scale and intl for values
cihanandac d0db84f
Merge branch 'master' into Teaser-block-image-resize-#4653
erral e4873b4
Add teaser block imageScale intl messages to the language files
cihanandac dd673eb
Merge branch 'master' into Teaser-block-image-resize-#4653
cihanandac File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Add a new property called 'image scale' to the schema of the Teaser Block. @cihanandac |
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
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { isInternalURL } from '@plone/volto/helpers'; | ||
import config from '@plone/volto/registry'; | ||
|
||
export function getTeaserImageURL({ href, image, align }) { | ||
export function getTeaserImageURL({ href, image, align, scale }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To keep backwards compatibility in the function, I think that the scale parameter should get the default value. export function getTeaserImageURL({ href, image, align, scale = 'teaser' }) { |
||
// The default scale used in teasers is the 'teaser' scale | ||
// except if it's customized otherwise in the teaser block settings | ||
// or if the teaser is center (top) | ||
const imageScale = | ||
align === 'center' | ||
? 'great' | ||
: config.blocks.blocksConfig['teaser'].imageScale || 'teaser'; | ||
: config.blocks.blocksConfig['teaser'].imageScale || scale; | ||
|
||
if (image) { | ||
// If the image is overriden locally in the teaser block | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The scale names should be passed through intl to get them translated.
For future reuse of the scale list, perhaps this list should be configurable in the block configuration, this way a developer can change the list of the available scales without overriding the component.
Moreover, right now we do not have an API endpoint to expose the available image scales, but in the future I think that the list of available scales should come from the API endpoint call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I will keep this in mind for the future contributions.