• Resolved liquidsponge

    (@liquidsponge)


    I’m using the snippet in the FAQ to add thumbnails to invoices. This has worked great for a few years, but in recent versions of Chromium and Chrome on both Windows and Linux the images do not appear in the print preview or on the printed invoice. I see a border around where the image should be, but no image. They do however appear if I preview the template through the settings or open the invoice in a new tab.

    This is possibly a bug in Chrome since Firefox works fine, but I can’t find any other references to this issue online. Is anyone else using the same snippet facing this issue and know if there are potential workarounds within Chrome? I’d prefer to avoid asking users to use a different browser just for invoices or have to go through a longer process to print by opening the invoice in a new tab first.

    • This topic was modified 5 years, 8 months ago by liquidsponge.
    • This topic was modified 5 years, 8 months ago by liquidsponge.
Viewing 1 replies (of 1 total)
  • Thread Starter liquidsponge

    (@liquidsponge)

    I did some further digging on this and noticed in the HTML for the generated invoice that the thumbnail image tag snippet returned by get_the_post_thumbnail has the loading="lazy" attribute to enable WordPress 5.5’s lazy loading. Removing this tag fixes the issue.

    My quick and dirty hack for others that may be facing the same issue:

    
    $thumbnail_snippet = get_the_post_thumbnail($product->id, array( 40, 40 ));
    $thumbnail_snippet = str_replace('loading="lazy"', '', $thumbnail_snippet);
    echo($thumbnail_snippet);
    
    • This reply was modified 5 years, 8 months ago by liquidsponge. Reason: Mark as resolved
Viewing 1 replies (of 1 total)

The topic ‘Thumbnail images missing in Chrome’ is closed to new replies.