Support » Plugin: PDF Invoices & Packing Slips for WooCommerce » AVIF compatibility

  • Resolved domdeutz

    (@domdeutz)


    Hello,

    I use shortpixel and try to generate and deliver my images in AVIF-Format. Unfoertunately this seems to cause compatibility issues in the pdf documents.

    Some pictures are not visible and it just shows “image not found or type unknown”

    Please find screenshot here.
    https://ibb.co/Db1sbbN

    Is there any workaround or are you working on compatibility for AVIF?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Yordan Soares

    (@yordansoares)

    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!

    Thread Starter domdeutz

    (@domdeutz)

    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

    Plugin Contributor Yordan Soares

    (@yordansoares)

    It could be possible, but first, please answer these questions:

    1. How are you adding the images to the Product column?
    2. 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
    Thread Starter domdeutz

    (@domdeutz)

    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

    Plugin Contributor Yordan Soares

    (@yordansoares)

    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?

    Thread Starter domdeutz

    (@domdeutz)

    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>';
    				}
    				?>
    Plugin Contributor Yordan Soares

    (@yordansoares)

    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>';
    }
    Thread Starter domdeutz

    (@domdeutz)

    That worked fine. Thank you very much! I will leave a review for the great support

    Plugin Contributor Yordan Soares

    (@yordansoares)

    I’m glad to hear that it worked!

    …and thanks in advance for your review 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.