Hi @domdeutz,
Unfortunately, the PDF engine we use only support JPEG
, PNG
, and WebP
.
Please note that some PHP extensions are needed to process PNG
and WebP
correctly. Go to WooCommerce > PDF Invoices > Status > System Configuration, within our plugin settings, to check if you have installed/activated the required PHP extensions.
Hope it helps!
Got it. I have both jpeg and AVIF variants of my images. I guess there is a way to force the pdf to pick the jpeg version instead of AVIF in order to display the image correctly in jpeg format?
Thanks
Dominique
It could be possible, but first, please answer these questions:
- How are you adding the images to the Product column?
- Do both
AVIF
and JPEG
images for a specific product have the same file name, regardless of the difference between their extensions? E.g. white-shirt.avif
/white-shirt.jpg
Hi, thanks for your reply.
1. I use shortpixel plugin. I have my NGNIX server configured in a way that AFIV is delivered when available.
2. Yes, exactly.
BR
Dominique
Thanks for providing more details, @domdeutz!
However, in my 1st question, I was referring to the Product column in the PDF invoice document: We don’t display the image thumbnail by default, are you maybe using a custom template or a code snippet to display the image there?
Ah got it. Yes, I use a custom template to include images. Sorry, wasn´t aware that thats not standard. I found below code in the template. I guess that this is creating the image in the Pdf file.
<tbody>
<?php foreach ( $line_items as $item_id => $item ) : $_product = $item->get_product(); ?>
<tr class="<?php echo apply_filters( 'wcfm_packing_slip_item_row_class', $item_id, $document_type, $order, $item_id ); ?>">
<td class="product" style="width:30%">
<style>
.product_image { width: 60px; height: 60px; }
.product_image img { width: 100%; height: 100% }
</style>
<?php
if (is_object($_product)) {
echo '<div class="product_image">' . $_product->get_image() . '</div>';
}
?>
<span class="item-name"><?php echo esc_html( apply_filters( 'wcfm_order_item_name', $item->get_name(), $item ) ); ?></span>
<?php
if ( $_product && $_product->get_sku() ) {
echo '<div class="wc-order-item-sku"><strong>' . __( 'SKU:', 'wc-frontend-manager' ) . '</strong> ' . esc_html( $_product->get_sku() ) . '</div>';
}
if ( ! empty( $item->get_variation_id() ) ) {
echo '<div class="wc-order-item-variation"><strong>' . __( 'Variation ID:', 'wc-frontend-manager' ) . '</strong> ';
if ( ! empty( $item->get_variation_id() ) && 'product_variation' === get_post_type( $item->get_variation_id() ) ) {
echo esc_html( $item->get_variation_id() );
} elseif ( ! empty( $item->get_variation_id() ) ) {
echo esc_html( $item->get_variation_id() ) . ' (' . __( 'No longer exists', 'wc-frontend-manager' ) . ')';
}
echo '</div>';
}
?>
Try replacing this part:
if (is_object($_product)) {
echo '<div class="product_image">' . $_product->get_image() . '</div>';
}
With this:
if ( is_object( $_product ) && ( $product_image = $_product->get_image() ) ) {
$product_image = str_replace( '.avif', '.jpg', $product_image );
echo '<div class="product_image">' . $product_image . '</div>';
}
That worked fine. Thank you very much! I will leave a review for the great support
I’m glad to hear that it worked!
…and thanks in advance for your review 🙂