-
Notifications
You must be signed in to change notification settings - Fork 7
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 option to guess and calculate width and height for an image format #36
Add option to guess and calculate width and height for an image format #36
Conversation
c22ef01
to
f0e7320
Compare
ff22987
to
43c9601
Compare
* 1: int|null, | ||
* } | ||
*/ | ||
private function guessAspectRatio($media, array $attributes): array |
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.
accessing the %sulu_media.image.formats%
parameter would allow us to not rely on the format key here. but i understand that it makes the method dependent on sulu.
another possibility would be trying to access the %sulu_media.image.formats%
parameter and fallback to this implementation if it is not available.
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.
i dont have a lot of experience with this package and i am not sure if anything sulu related is accessed somewhere else. if yes, i think it would be nice to use %sulu_media.image.formats%
. if not, we should probably not start doing it 🙂
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.
Currently the web twig extension has no sulu dependencies and so are sulu independent. As sulu_media.image.formats
is no service just an array configuration which we could reuse without a dependency to sulu.
I'm fine to add imageFormatsConfiguration
as parameter and use it when is configured and else fallback to it. What do you think?
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.
i think it would be nice to do that, because the feature would not depend on the format of the keys then 🙂
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.
Did update the extension!
Co-authored-by: nnatter <niklas.natter@gmail.com>
b602dc1
to
e109c5c
Compare
e109c5c
to
cf8e108
Compare
Co-authored-by: nnatter <niklas.natter@gmail.com>
Set width and height attribute automatically
Since Sulu 2.3 the original image width and height are save as properties.
This allows us the guess the width and height dimension of a given image format.
With setting the width and height attribute modern browsers avoid a layer shifts
and the page will not jump when images are loaded.
This feature can be activated the following way:
So if we have an original image of 1920x1080 and have a image format called 100x:
Will add automatically the width and height attributes to the imgage tag:
This only works when writing image formats in specific format 100x, x100, 100x100, 100x100-inset, 100x@2x, ...
for all other cases this option not be activated.
fixes #36