Skip to content

Modern image formats not used for fixed background image in Cover Block #2111

@westonruter

Description

@westonruter

Bug Description

If you create a Cover Block and add an image with a fixed background, the image is not replaced with AVIF/WebP when the block is rendered on the frontend. The original JPEG (or other) format is used.

These images are especially important to have a modern image format used, because there is no srcset to reduce the size.

Steps to reproduce

  1. Enable Modern Image Formats.
  2. Upload an image to the media library so that it generates a modern image format.
  3. Add a Cover Block.
  4. Add the uploaded image to the Cover block.
  5. Enable "fixed background" in the Cover block's settings.
  6. View the Cover block on the frontend and see that the modern image format is not used.

Cover Block Markup

<div
  class="wp-block-cover alignwide is-light has-parallax"
  style="border-radius: 100px"
>
  <div
    class="wp-block-cover__image-background wp-image-8 size-large has-parallax"
    style="
      background-position: 50% 50%;
      background-image: url(https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-1024x668.jpg);
    "
  ></div>
  <span
    aria-hidden="true"
    class="wp-block-cover__background has-background-dim"
    style="background-color: #93825b"
  ></span>
  <div
    class="wp-block-cover__inner-container has-global-padding is-layout-constrained wp-block-cover-is-layout-constrained"
  >
    <h2
      class="wp-block-heading has-text-align-center has-base-color has-accent-6-background-color has-text-color has-background has-link-color has-xx-large-font-size wp-elements-f7ac82b376aa52ed5a9058a4e2fb6f3e"
      style="border-radius: 100px"
    >
      <strong>Bison</strong> 🦬
    </h2>
  </div>
</div>

Image Block Markup

This is using the same underlying image, and it is successfully rendered as AVIF:

<figure class="wp-block-image size-large">
  <img
    loading="lazy"
    decoding="async"
    width="1024"
    height="668"
    src="https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-1024x668-jpg.avif"
    alt=""
    class="wp-image-8"
    srcset="
      https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-1024x668-jpg.avif  1024w,
      https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-300x196-jpg.avif    300w,
      https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-768x501-jpg.avif    768w,
      https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-1536x1002-jpg.avif 1536w,
      https://wcus-perf-talk-demo.local/wp-content/uploads/2025/06/American_bison_k5680-1-2048x1336-jpg.avif 2048w
    "
    sizes="auto, (max-width: 1024px) 100vw, 1024px"
  />
</figure>

Metadata

Metadata

Assignees

Labels

[Plugin] Modern Image FormatsIssues for the Modern Image Formats plugin (formerly WebP Uploads)[Type] BugAn existing feature is broken

Type

Projects

Status

Done 😃

Relationships

None yet

Development

No branches or pull requests

Issue actions