Skip to content

Enable webp/avif support for images outputed with wp_get_attachment_image #138

@matthewgrzegorczyk

Description

@matthewgrzegorczyk

Shorptixel version: 5.6.2

I am trying to use webp/avif compression on the page, but as the site is custom build app on roots/bedrock I had to fix several things as the option of delivering next gen image formats via picture tag using wordpres hook didn't work out of the box.

image

I've notice that in the FrontController the replacement of <img> tag with <picture> tag happens only for the_content, the_excerpt and post_thumbnail_html.
Is it possible that we add in here: https://github.com/short-pixel-optimizer/shortpixel-image-optimiser/blob/master/class/Controller/FrontController.php#L46
another option to run convertImgToPictureAddWebp?
add_filter('wp_get_attachment_image', array($this, 'convertImgToPictureAddWebp'), 10, 4);

If not, maybe it's possible to add do_action hook which would enable advanded users to register it on their own?
do_action('shortpixel/init_webp_hooks', $this, $webp_option)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions