Skip to content

Enable "animated": true in Sharp #409

@zawilliams

Description

@zawilliams

Sharp has an option to resize with "animated": true or "animated": false in the edits in the base64 edits config. Within the Craft admin, resized .gifs are not animated, but I'd like them to be animated.

If I'm trying to check for file type and setting "animated": true, is the recommended way to do this using a custom image transform class? Like outlined here: https://nystudio107.com/docs/image-optimize/advanced.html#writing-your-own-image-transform-class

If I were inside the SharpImageTransform.php class and modify it like below, I get the animation happening in Craft admin:

if (!empty($edits)) {
    $config['edits'] = $edits;
}
        
$config['edits']['animated'] = true; // new line that could be conditional

Is there another way that I should be going about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions