Closed BPScott closed 10 years ago
This started here:
I think it might actually be worth making a new image every 8 pixels, from what I can tell by the RespImages community chatter JPEG has some magic formula where images that are factors of 8x8 compress much better than other dimensions.
So instead of having a long array, the idea was to calculate dynamically the width of an image. That's basically what is tested here:
The idea is that Imager still works the same way, but the width picker logic can be overridden for special needs. It has to just return a value. This is the only responsability of that function, simple.
@oncletom heya, just checking if this ready for me to review (looks like it)?
@Integralist yep, ready :-) it was an "almost" working feature, previously badly implemented.
It looks like this got merged into the browsers-compatibility branch, not master. Should this have gone to master as browser-compatability was already merged?
@BPScott I'll rebase as soon as I end up the current meeting :-)
@BPScott okay merged in master
:-)
The readme suggests that I can pass a function to availableWidths, however the example provided does not appear to work as expected.
Codepen Demo
As an aside:
What is the use-case for defining availableWidths as a function? I know it allows people to customize the function that runs when
replaceImagesBasedOnScreenDimensions
is called, but surely that's core functionality to Imager? Anybody that wants to overwrite it would also have to reimplementdetermineAppropriateResolution
themselves otherwise they would end up hammering their image service on every resize. To me this feels like we're giving people the option to reimplement core internals at a too deep level without an obvious reason why they would need to.