humanmade / asset-manager-framework

A framework for overriding the WordPress media library with an external asset provider, such as a DAM
GNU General Public License v2.0
155 stars 7 forks source link

Ensure an image with no size meta, has the appropriate size meta. #59

Closed robindevitt closed 2 years ago

robindevitt commented 2 years ago
Related Issue

https://github.com/humanmade/altis-cms/issues/626 An image renders an incorrect size to what was expected when viewing the editing a post.

The image had no appropriate sizing for the different registered sizes. All registered image sizes were being given the full dimensions of the image but rendered at a different size.

Solution

Ensure that the registered image sizes are applied to the relevant sizes rather than applying the full image dimensions to each registered size. The full dimensions are used as a fallback.

roborourke commented 2 years ago

AMF doesn’t do this because it can’t know if the external source has images with those exact dimensions that the theme is requesting, they can be added if the provider implements the resize interface e.g. https://github.com/humanmade/altis-media/blob/master/inc/global_assets/class-tachyon-provider.php

roborourke commented 2 years ago

I would maybe look at why that file I linked above is failing to return the right URL for the size being requested

robindevitt commented 2 years ago

So the image URL's appear to be correct from the function resize in this file https://github.com/humanmade/altis-media/blob/master/inc/global_assets/class-tachyon-provider.php .

*/tachyon/sites/2/2022/09/verticz-squencz-HAmKh06RZb0-unsplash.jpg?resize=150%2C150&crop_strategy=smart
*/tachyon/sites/2/2022/09/verticz-squencz-HAmKh06RZb0-unsplash.jpg?fit=300%2C300
*/tachyon/sites/2/2022/09/verticz-squencz-HAmKh06RZb0-unsplash.jpg?fit=768%2C0
*/tachyon/sites/2/2022/09/verticz-squencz-HAmKh06RZb0-unsplash.jpg?fit=1024%2C590
*/tachyon/sites/2/2022/09/verticz-squencz-HAmKh06RZb0-unsplash.jpg?fit=2048%2C590