-
Notifications
You must be signed in to change notification settings - Fork 68
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
SSViewer image renders loading
attribute
#450
SSViewer image renders loading
attribute
#450
Comments
Proposed implementation
We should just supply the width and height attributes on our end if lazy loading is enabled. |
In the intention here to return the whole attribute e.g. Because of this I think it would make sense to return the entire
The original floated idea was to have a callable function from the template e.g.
This value won't be configurable, so it should just return 'loading="lazy"'
I think I agree here. This would imply a bit of a change with the current default behaviour which doesn't specify the width and height on DBFile_image.ss. This might have some set image dimensions via CSS, though this is weird. We should probably always be setting width and height here. |
Might make more sense to have this in You also need to consider what should happen if you call this on a regular file. How are you planning on getting the loading attribute in Don't really have an opinion on rather we call it |
I'd probably prefer straight
There's currently no signs on the horizon that there will ever be any loading attributes beyond 'lazy' | 'eager' | 'auto' (which is eager). There's also no sign of this, though it may one day happen that browsers change their default behaviour from eager to lazy. In this scenario, the |
I think we should just use an if condition, then build the html inside the template. Returning an HTML string like that from a PHP function seems weird. We can just skip rendering the attribute if it's
Correct, this will be added to
That's what I meant by adding the API earlier.
I'm in favor of
We don't know that for sure.
We don't know that for sure either. What WP does is allow |
I think We should try our best to replicate behaviours for similar classes. So adding a You seem to have this nailed down. |
e.g. Given we've already decided the default value is non-configurable, it seems like the logical options that use a strict type or no argument are:
|
I guess if you're going to have a method that accepts a value, calling If the method doesn't accept a parameter, than it needs a matching method to undo it. Let's maybe pick 4/5 options throw them in the bespoke channel and see what makes the most sense to folks. If the point of this is to get devs to adopt it, it's probably worth spending some time figuring out what makes the most sense to the average dev. It shouldn't hold back André from progressing this. It's just changing a method name later on. |
Overview
Modify
DBFile.php
andDBFile_image.ss
to render the new lazy-loading attribute.Background: https://forum.silverstripe.org/t/browser-level-lazy-loading-from-silverstripe-cms/4218
Acceptance Criteria
loading="lazy"
attribute to be added when you render an image in the templateloading="lazy"
attribute will only be added to images where dimensions are definedNotes
PR's
The text was updated successfully, but these errors were encountered: