Closed kinglozzer closed 1 year ago
I'm just trying to wrap my head around the implications of this - do you have a more realistic example of where this would cause a problem?
I'm just trying to wrap my head around the implications of this - do you have a more realistic example of where this would cause a problem?
So my use case is this module, the lazyload setting currently isn’t copied through so I can’t enable/disable loading=lazy
for specific images, only globally. Any extension that needs to know if an image is lazy loaded or not would be affected though
Fixed in 1.12.1
Example:
Calling
$Image.LazyLoad(false).Test
in a template will always outputtrue
.This seems to be because the
ImageManipulation
trait is applied to bothFile
(Image
extendsFile
) andDBFile
. Calling.LazyLoad(false)
calls the following code:https://github.com/silverstripe/silverstripe-assets/blob/ce9464b6282c34e37324987ea2dd74cae89c50ca/src/ImageManipulation.php#L1101-L1111
This then returns the a
DBFile
instance with the attribute set, but the attribute is never set on theImage
object itself. Setting the attributes on theImage
object via$file->getFailover()->initAttributes()
fixes this, but goes against the documentation forImageManipulation::setAttribute()
which states the method is supposed to be immutablePRs