• Hi Greg,

    Please can you add support for this plugin from wordpress performance team Modern Image Formats https://ww.wp.xz.cn/plugins/webp-uploads/ The plugin converts images in jpeg to webp or avif formats reducing file size, the plugin also has setting to delete the jpeg versions and retain the new formats.

    This feature would be helpful as modern phones have large camera resolutions

    Ive tested with wpadverts but my users are still uploading large jpeg image files, I would prefer to auto delete the jpeg images and retain the converted webp files for images uploaded by users.

    This feature would really help with file storage and faster page loads for classifieds due to low image file size in webp and avif formats

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter teeboy4real

    (@teeboy4real)

    Currently WebP versions are only generated for images to the Media Library. WebP versions are not generated for JPEG images that are added to site in other ways, Adding support for the wpadverts media uploader would be awesome

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,

    i will look into integrating with one of the WebP plugins, it should be available in the next release, although i cannot tell right now which plugin i will be integrating with, proably the one with the most installs that does not rely on any third-party services.

    Plugin Author Greg Winiarski

    (@gwin)

    BTW. I tested with Converter for Media plugin https://pl.ww.wp.xz.cn/plugins/webp-converter-for-media/ and it works fine on my dev site without any special changes, few notes though:

    1. The plugin does not seem to do conversion on-upload but rather somewhere in the background, so after uploading a file it might look like the file is a JPG file, but in the preview or when viewing the Ad it should be already converted to webp.
    2. The Converter for Media overwrites file paths, so in the source code the file will still have .jpg or .png extension, but if you investigate with Chrome Developer Tools for example you will see the file type is webp (i suppose it is doing this to avoid changing your posts and pages content).
    Thread Starter teeboy4real

    (@teeboy4real)

    Thanks for the feedback Greg but I suggested this plugin https://ww.wp.xz.cn/plugins/webp-uploads/ because wordpress team is considering adding it into wordpress core see more at https://wptavern.com/webp-by-default-merged-into-core-for-wordpress-6-1 and https://make.ww.wp.xz.cn/performance/2022/07/26/welcome-to-the-performance-team-blog/

    Plugin Author Greg Winiarski

    (@gwin)

    These blog posts are almost 3 years old, it’s unclear when and if this will be merged.

    Thread Starter teeboy4real

    (@teeboy4real)

    Thanks for the feedback Greg, I dont think the Converter for Media plugin is suitable for me due to its limitations and also considering the fact that hosting plan has limited Nvme ssd storage. immediate conversion on upload is better

    Thread Starter teeboy4real

    (@teeboy4real)

    Hello Greg,

    This code below seems to work for this plugin https://ww.wp.xz.cn/plugins/webp-uploads/

    Kindly review

    /**
    * Generate Modern Image Formats for new WPAdverts gallery uploads
    */
    function wpadverts_generate_modern_formats( $attachment_id, $post ) {
    // Target only WPAdverts gallery uploads
    if ( empty( $_REQUEST['adverts_gallery'] ) ) return;

    // Ensure metadata exists - triggers Modern Image Formats automatically
    if ( ! wp_attachment_is_image( $attachment_id ) ) return;

    $metadata = wp_get_attachment_metadata( $attachment_id );
    $file = get_attached_file( $attachment_id );

    if ( ! $metadata && $file && file_exists( $file ) ) {
    wp_generate_attachment_metadata( $attachment_id, $file );
    }
    }
    add_action( 'wp_insert_attachment', 'wpadverts_generate_modern_formats', 20, 2 );

    /**
    * Enable fallback support (optional)
    */
    function wpadverts_enable_modern_fallback() {
    if ( current_user_can( 'manage_options' ) && ! get_option( 'webp_enable_fallback' ) ) {
    update_option( 'webp_enable_fallback', true );
    }
    }
    add_action( 'init', 'wpadverts_enable_modern_fallback' );

    Thread Starter teeboy4real

    (@teeboy4real)

    Any feedback sir

    Thanks

    Plugin Author Greg Winiarski

    (@gwin)

    I haven’t looked at it, but if this code works for you put it in your theme functions.php file or create a new blank plugin (https://wpadverts.com/blog/how-to-use-code-snippets-in-wordpress/) and put it there, you do not need it in the WPAdverts core.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Support for Modern Image Formats plugin’ is closed to new replies.