How to display product image in invoice?
Yes I can confirm the path to the image is correct and the image is there. If the image is not there the error message is different.
Thanks
Please Log in or Create an account to join the conversation.
Then how about trying with the URL of the image instead of the relative path ?
Please Log in or Create an account to join the conversation.
I'm using the code you pasted here earlier in this thread
I believe that does use the URL of the image - how would I change that to use the relative path?
Please Log in or Create an account to join the conversation.
The variable $img->url should normally contains something like that:
"/images/com_hikashop/upload/thumbnails/100x100f/myimage.jpg"
That' a relative path. So you already are using a relative path.
What's before the first / is filled by the browser (or the HTML2PDF library in this instance).
So what you can do is prepend the URL of the website so that you force it to use the full URL instead of letting it guess it.
So for example, instead of:
And that's just what I remember from memory.
The best would be to first directly echo the variable $img->url to see what's inside so that you can prepend what's needed accordingly.
Please Log in or Create an account to join the conversation.
Thanks for the reply.
This produces the same result.
I echo the result to make sure the URL was formed correctly etc but still the same issue?
Please Log in or Create an account to join the conversation.
Can you provide an example of URL that was generated for a thumbnail ?
If you can open it with your browser and see the image, then it means that the URL is correct. In that case, it means there is a problem with the server settings preventing PHP from accessing URLs (most likely with allow_url_fopen : www.a2hosting.com/kb/developer-corner/ph...-url-fopen-directive ).
If you can't open the URL with the browser, then there is a problem with the URL itself.
Please Log in or Create an account to join the conversation.
allow_url_fopen is tunred on yes (see attached)
Yes you can access the images if you go to the resulting URL, they work fine.
Example URL
www.totalfootballdirect.com/images/com_h...c_academy_bundle.png
Or tried:
/images/com_hikashop/upload/thumbnails/50x50sO/fitc_academy_bundle.png
Thank you
Please Log in or Create an account to join the conversation.
As I said, if the URL added in the invoice is correct, then if you get an error about it, it normally means that the HTML2PDF library was not able to get the image. It could be an issue with allow_url_fopen, but it could be something else. For example, a rule in your web server configuration preventing some user-agent from accessing files (to prevent bots from accessing them), or a similar rule in a htaccess file.
Please Log in or Create an account to join the conversation.
I have checked .htaccess, this is not the issue. The hosts ask what "user-agent" could be preventing the access? So they can try to trace the issue.
You can access the image via the URL so not sure why you think its not accessible?
Please Log in or Create an account to join the conversation.
It's quite common to block user agents on web servers :
techexpert.tips/apache/apache-blocking-user-agent-access/
Most security extensions for Joomla usually have some mechanism to filter user-agents.
There are also security rules for htaccess files to block user-agents for Joomla:
gist.github.com/uzielweb/11997372b325d38218b0b28bc90062ea
The library used by the plugin to generate the PDF is called TCPDF. It uses file_get_contents to get the data of each image without sepcifying a user-agent. In that case, either PHP will use the user-agent specified in the php.ini or won't send any user-agent:
www.php.net/manual/en/context.http.php
So I can't say what user-agent is used as it depends on the way your server is setup. What's sure is that it's quite likely different from what a browser sends and could explain why TCPDF is unable to load the image while a browser loads it fine.Value to send with User-Agent: header. This value will only be used if user-agent is not specified in the header context option above.
By default the user_agent php.ini setting is used
Please Log in or Create an account to join the conversation.
Thanks for the info - I went back to the hosting company which they have replied with:
Thanks for waiting, We've had a look on our side and we cannot see any issues with the server itself. The permissions and ownerships of the files and folders have also been looked at but this doesn't look to be due to the server or platform.
Whats ODD is now it works - so someone did something lol - thanks for your help.
Please Log in or Create an account to join the conversation.