• I’m using Woocommerce Custom Product Addons for customer to choose a colour of gift wrap or card to be sent with their order and the images of these choices are not working in the PDF invoice. The image is shown as a square with cross and says ‘Image not found or type unknown’.

    I’ve tried to follow suggestions in this support forum but nothing has fixed it.

    System Configuration all good.
    Write Permissions all writable.
    I have General > Test mode ticked.
    I have Documents > Invoice > ‘Always use most current settings’ ticked.
    I am using a custom template but all I did was add an address to it.

    Please could you help?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Contributor alexmigf

    (@alexmigf)

    Hello @dynamek

    Could you try to enable the HTML output under the Status tab and inspect the image URL?

    Let me know what you find.

    Thread Starter dynamek

    (@dynamek)

    When showing using html output the image shows fine.

    Output is

    <p class="wcpa_image"><img style="width:90px" src="https://www.atlantic-shore.co.uk/wp-content/uploads/2021/01/Pink-Polka-Dot.png" width="90">Pink<span class="wcpa_cart_price">(<span class="wcpa_price"><span class="woocommerce-Price-currencySymbol">£</span><span class="price_value">1.00</span></span>)</span></p>

    • This reply was modified 3 years, 4 months ago by dynamek.
    • This reply was modified 3 years, 4 months ago by dynamek.
    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @dynamek

    Could you provide us the information below?

    • A screenshot of the ‘Write Permissions’ panel in the Status tab of the PDF invoice settings
    • The exact code you used for the image URL
    Thread Starter dynamek

    (@dynamek)

    Write permissions sent by email.

    I’m not sure what you want for the ‘Exact code used for image URL’. I am using the Woocommerce Custom Product Addons plugin so I’m just adding an image to their form builder.

    Image URL I am adding is what automatically would be added in media admin – https://www.atlantic-shore.co.uk/wp-content/uploads/2021/01/Blue-Polka-Dot.png for example

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @dynamek

    If this is a custom template, how are you pulling the “Woocommerce Custom Product Addons” data?

    Thread Starter dynamek

    (@dynamek)

    I haven’t changed anything from the Simple Template other than added a returns address. So I’m guessing it is using the standard meta code within the Simple Template?

    The html shows inside
    <span class="item-meta"><ul class="wc-item-meta"><li>

    which is
    <span class="item-meta"><?php echo $item['meta']; ?></span>

    • This reply was modified 3 years, 4 months ago by dynamek.
    • This reply was modified 3 years, 4 months ago by dynamek.
    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @dynamek

    Could you please try the code snippet below?

    add_filter( 'wpo_wcpdf_get_html', function ( $html, $document ) {
    	if ( !class_exists('DOMDocument') || stripos( $html, "</html>" ) === false ) {
    		return $html;
    	}
    	$dom = new DOMDocument();
    	$dom->loadHTML( $html );
    
    	foreach ( $dom->getElementsByTagName( 'img' ) as $image ) {
    		$image->setAttribute( 'src', str_replace( trailingslashit( content_url() ), trailingslashit( WP_CONTENT_DIR ), $image->getAttribute( 'src' ) ) );		
    	}
    
    	return $dom->saveHTML($dom);
    }, 10, 2);

    If you never worked with actions/filters please read this documentation page: How to use filters

    Thread Starter dynamek

    (@dynamek)

    Thanks that’s looking like it will work now!
    Styling isn’t ideal but will do if there’s nothing that can be done.

    Plugin Contributor alexmigf

    (@alexmigf)

    Hi @dynamek

    Glad it worked!

    Styling can be done using custom styles.

    Thread Starter dynamek

    (@dynamek)

    Ah great, thanks! ??

    Thread Starter dynamek

    (@dynamek)

    Just to say I’m getting PHP warnings from this code:

    mod_fcgid: stderr: PHP Warning: DOMDocument::loadHTML(): Tag bdi invalid in Entity

    Do you have a fix?

    Thread Starter dynamek

    (@dynamek)

    Constant apache errors from this code you suggested… and could be causing issues with another plugin. Fix please!

    mod_fcgid: stderr: PHP Warning: DOMDocument::loadHTML(): Tag bdi invalid in Entity, line: 391 in /functions.php on line 359 Apache error

    Thread Starter dynamek

    (@dynamek)

    Also we to have a problem where the PDF does show the images correctly but they don’t print out – they print the square crossed box. Help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Image not found or type unknown’ is closed to new replies.