{"id":65,"date":"2021-03-29T09:57:00","date_gmt":"2021-03-29T09:57:00","guid":{"rendered":"https:\/\/imagify.io\/documentation\/?p=65"},"modified":"2025-09-24T12:31:50","modified_gmt":"2025-09-24T12:31:50","slug":"my-images-are-broken","status":"publish","type":"post","link":"https:\/\/imagify.io\/documentation\/my-images-are-broken\/","title":{"rendered":"My images are broken"},"content":{"rendered":"\n<div class=\"message-panel blue\"><i class=\"fa fa-exclamation-circle\"><\/i><span class=\"message-panel__title\">TL;DR<span class=\"message-panel__message\">In Imagify settings, switch WebP display setting from \u201cUse &lt;picture&gt; tags\u201d to \u201cUse rewrite rules\u201d as long as your website doesn&#8217;t use a CDN or Cloudflare.<\/div>\n\n\n\n<p>If you&#8217;re seeing broken layouts, missing images, or degraded image quality on your site, this could be due to how Imagify is serving Next-Gen images like WebP.<\/p>\n\n\n\n<p>Imagify provides two options for displaying Next-Gen images on your site:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Using <code>&lt;picture&gt;<\/code> Tags<\/strong><\/li>\n\n\n\n<li><strong>Using Rewrite Rules (Recommended)<\/strong><\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Using <code>&lt;picture&gt;<\/code> Tags<\/h3>\n\n\n\n<p>The <strong><code>&lt;picture&gt;<\/code> tag method<\/strong> works by replacing <code>&lt;img&gt;<\/code> tags with <code>&lt;picture&gt;<\/code> tags to serve WebP images. While this method is effective for most browsers, some themes or plugins may not be fully compatible, which can result in broken layouts or missing images.<\/p>\n\n\n\n<p><strong>Solution:<\/strong><br>To check if the <code>&lt;picture&gt;<\/code> tag method is causing the issue, you can disable the <strong>\u201cDisplay images in Next-Gen format on the site\u201d<\/strong> option in your Imagify settings. After disabling, clear all caches (including any caching plugins, browser cache, and CDN cache if applicable) and see if the issue is resolved.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"408\" src=\"https:\/\/imagify.io\/documentation\/wp-content\/uploads\/2024\/09\/image-5-1024x408.png\" alt=\"\" class=\"wp-image-1081\" srcset=\"https:\/\/imagify.io\/documentation\/wp-content\/uploads\/2024\/09\/image-5-1024x408.png 1024w, https:\/\/imagify.io\/documentation\/wp-content\/uploads\/2024\/09\/image-5-300x119.png 300w, https:\/\/imagify.io\/documentation\/wp-content\/uploads\/2024\/09\/image-5-768x306.png 768w, https:\/\/imagify.io\/documentation\/wp-content\/uploads\/2024\/09\/image-5.png 1047w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><strong>Workaround:<\/strong><br>If you confirm that the <code>&lt;picture&gt;<\/code> tag method is causing the issue and you cannot switch to rewrite rules, you can try using this <a href=\"https:\/\/github.com\/wp-media\/imagify-helpers\/raw\/master\/webp\/imagify-keep-attributes-on-img-tags\/imagify-keep-attributes-on-img-tags.zip\" target=\"_blank\" rel=\"noopener\">helper plugin<\/a> to keep the attributes in the <code>&lt;img&gt;<\/code> tag instead of converting them to <code>&lt;picture&gt;<\/code>. This workaround can help maintain compatibility with your theme. It would be good to test it to ensure that it works properly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Rewrite Rules (Recommended)<\/h3>\n\n\n\n<p>If you\u2019re not using Cloudflare or a CDN, switching to the <strong>Rewrite Rules<\/strong> method is a safer way to serve Next-Gen images. This method doesn\u2019t modify your site&#8217;s HTML but adds rules to your <code>.htaccess<\/code> file (on Apache servers) to serve WebP images smoothly without affecting your site\u2019s layout.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Apache Servers<\/strong>: Imagify automatically adds the necessary rewrite rules to your <code>.htaccess<\/code> file, so no further action is needed.<\/li>\n\n\n\n<li><strong>Nginx Servers<\/strong>: In some cases, Imagify may not be able to add the rewrite rules automatically due to server restrictions. You can verify this and manually add the rules to the <code>conf\/imagify.conf<\/code> file.<\/li>\n<\/ul>\n\n\n\n<p>Code to add:<\/p>\n\n\n<div class=\"wp-block-wab-pastacode\">\n\t<div class=\"code-embed-wrapper\"> <pre class=\"language-markup code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-markup code-embed-code\"># BEGIN Imagify: rewrite rules for webp<br\/><br\/>    # Vary: Accept for all requests to jpeg, png, and gif.<br\/>location ~* ^(\/.+)\\.(jpg|jpeg|jpe|png|gif)$ {<br\/>    add_header Vary Accept;<br\/><br\/>    set $canavif 1;<br\/>    if ($http_accept !~* &quot;avif&quot;)       { set $canavif 0; }<br\/>    if (!-f $request_filename.avif)    { set $canavif 0; }<br\/>    if ($canavif = 1) {<br\/>        rewrite ^(.*)$ $1.avif break;<br\/>    }<br\/><br\/>    set $canwebp 1;<br\/>    if ($http_accept !~* &quot;webp&quot;)       { set $canwebp 0; }<br\/>    if (!-f $request_filename.webp)    { set $canwebp 0; }<br\/>    if ($canwebp = 1) {<br\/>        rewrite ^(.*)$ $1.webp break;<br\/>    }<br\/>}<br\/><br\/># END Imagify: rewrite rules for webp<\/code><\/pre> <div class=\"code-embed-infos\"> <a href=\"https:\/\/gist.github.com\/markonikolic985\/640c5c1fd91b8940eac859fce7cedf73\" title=\"See imagify-nginx-rewrite-rules.conf\" target=\"_blank\" class=\"code-embed-name\" rel=\"noopener\">imagify-nginx-rewrite-rules.conf<\/a> <a href=\"https:\/\/gist.githubusercontent.com\/markonikolic985\/640c5c1fd91b8940eac859fce7cedf73\/raw\/1e7444fece17568af58fe94adfbf85151d85a2b8\/imagify-nginx-rewrite-rules.conf\" title=\"Back to imagify-nginx-rewrite-rules.conf\" class=\"code-embed-raw\" target=\"_blank\" rel=\"noopener\">view raw<\/a> <\/div> <\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Summary of Steps:<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>If you experience broken images, try disabling the <code>&lt;picture&gt;<\/code> tags in Imagify settings.<\/li>\n\n\n\n<li>If the issue is resolved, you can either continue using the rewrite rules or use the helper plugin to retain the <code>&lt;img&gt;<\/code> tag attributes while using the <code>&lt;picture&gt;<\/code> tag method.<\/li>\n\n\n\n<li>If you&#8217;re not using Cloudflare or a CDN, switching to the <strong>Rewrite Rules<\/strong> method is recommended for smoother Next-Gen image serving.<\/li>\n<\/ol>\n\n\n\n<p>If you need further assistance or help with the issue, feel free to contact our support team.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>TL;DRIn Imagify settings, switch WebP display setting from \u201cUse &lt;picture&gt; tags\u201d to \u201cUse rewrite rules\u201d as long as your website doesn&#8217;t use a CDN or Cloudflare. If you&#8217;re seeing broken layouts, missing images, or degraded image quality on your site, this could be due to how Imagify is serving Next-Gen images like WebP. Imagify provides [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[23,15,22],"class_list":["post-65","post","type-post","status-publish","format-standard","hentry","category-image-optimization","category-webp","tag-broken-layout","tag-image-optimization","tag-webp"],"_links":{"self":[{"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/posts\/65","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/comments?post=65"}],"version-history":[{"count":23,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/posts\/65\/revisions"}],"predecessor-version":[{"id":1185,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/posts\/65\/revisions\/1185"}],"wp:attachment":[{"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/media?parent=65"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/categories?post=65"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/imagify.io\/documentation\/wp-json\/wp\/v2\/tags?post=65"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}