Broken png image using Laravel Asset Pipeline despite 200 OK status - php

I'm using Codesleeve/asset pipeline on my Laravel project to serve css, js and image files. It on the whole works fine but there is an issue with displaying css-loaded images. The image does not display and shows the browser's "broken image" symbol when loading it directly (http://art.ipscap.com/assets/select2.png for example): e.g.
Upon inspecting the page it shows the image is loaded successfully with 200 OK status (or cached) but there seems to be an error displaying it. Seeing as the image in question displays fine on my local machine and the problem is only in production is there a way to diagnose this issue?
Edit: Still haven' t managed to find a solution for this. For reference the live broken image url is https://art.ipscap.com/assets/select2.png. The image itself is in app/assets/images/select2.png and the readme in the same directory states:
If you place an image here called foobar.png then you can access that image by going to http://<hostname>/assets/foobar.png
I find it strange as the image does not fail to load but is being broken by asset pipeline. The same does not seem to occur to other images in the app such as the header jpeg image.

Do you use different server software on your local and production server? I see the production uses nginx. In that case, you might have to add something to your config as stated here:
https://github.com/CodeSleeve/asset-pipeline#can-i-use-nginx

Related

No thumbnail shown in Laravel's File Manager

Currently using Laravel version 5.7.13 with Unisharp's CKEditor & File-Manager
I successfully linked the directories to show the images that I have in the file. However, the thumbnails were not shown.
Is the problem lies in my directory routing (lfm.php)?
Edit 1: Just found the solution for my problem, apparently the thumbnails were "broken" due to the link provided. Then, I changed my filebrowserImageBrowseUrl in the CKEditor's script to a raw url without the 'index.php'.
Before: ../../laravel-filemanager?type=Images
After: http : //localhost/[root-directory]/public/laravel-filemanager?type=Images
In conclusion, the 'index.php' is preventing the thumbnails from showing up.
Now it's working perfectly.

dompdf image not found on live server

After several hours of searching, I am still unable to resolve this issue. I am having a problem with displaying images in a PDF file generated by dompdf library.
I have an editor tinyMCE where a user can upload images, edit his page, and see a preview in PDF format with a Button press.
One important thing here: I am using 'convert_urls : true' in tinyMCE's configuration which converts the image src = "https://mysite.com/public/images/image_name.png", necessary for the PDF library to display them.
I set the required dompdf configurations:
def("DOMPDF_ENABLE_REMOTE", true);
Here I found that it will appear after changing the attached CSS with a dompdf like:
img { display:block }
All still in vain.
Note: Everything is working fine on localhost. But on the staging server, I get a message box having a cross inside it saying "image not found" and displaying the image path. When I click on that path, the image is already there on my server. I wonder why dompdf is giving me this message?
I already faced same kind of issue. solution is very simple when Dompdf does not accept url with http format. Try with full document root.
Instead of using https://example.com/public/images/image_name.png try with /var/www/mysite/public/images/image_name.png
Use a absolute path for external css and images than live path! its worked for me also

mPDF not rendering images (mPDF error: IMAGE Error Could not find image file)

We are getting plagued with this which started in April on working server. Everything was fine with our application until the customer reported that PDFs were no longer displaying the images.
Our PDF is generated via a HTML render first. When the HTML render is displayed the Image shows correctly. Also the image shows correctly if the image URL as noted in the mPDF is copied and pasted into a new tab.
However... If we load the image from a DIFFERENT DOMAIN then the image is rendered correctly. loading the image via absolute path, relative path or URL path all result in this error:
mPDF error: IMAGE Error (http://www.aibsonline.co.uk/logo.gif): Could not find image file
But, as you will see the logo url works when pasted. File permissions have been tested (which is why it is in the root) as standard and up to 777. Server is a Linux server in both cases we have seen so far.
HTML Code that renders the logo:
<div id="logo_wrapper" class="left">
<img width="107" height="76" src="<?php echo base_url('logo.gif'); ?>" />
</div>
At a real loss with this one and it is beginning to affect more and more clients.
Any help gratefully received.
UPDATE
The image renders if the rendering code and the image are in the same directory and we do NOT use an absolute path, eg.
<img width="107" height="76" src="logo.gif" />
I ran across this issue today. My problem was that the domain name I was using didn't resolve back to the server when accessed from the server. I added an entry to the hosts file on the server, and images started showing.
Your equivalent hosts file entry of what fixed my problem would be:
127.0.0.1 www.aibsonline.co.uk
Or otherwise ensure that www.aibsonline.co.uk resolves to your server in the DNS that your server uses.
It appears that mPDF accesses images as a cURL web client, so DNS on the server needs to be configured correctly to refer back to itself.
I had a similar issue and I solve by following:
1.Check if gd library is installed and enable in your php ini file. If not install gd library.
2.Turn on debug variable
$mpdf = new mPDF();
$mpdf->showImageErrors = true;
3.Try inter-changing absolute/relative path for the image
<img src="http://someDomain/directory/image.jpg">
<img src="./directory/image.jpg">
Hope this helps.
With same issue, I found that get_headers() returns:
"HTTP/1.1 412 Precondition Failed"
Provider says this was due to web firewall, because the request was badly formed and the user_agent not set.
An ini_set('user_agent', 'Mozilla/5.0'); solved the problem.
In a WordPress plugin using mpdf, mpdf doesn't use WordPress http classes and doesn't set user_agent. I solved this by adding in mu-plugins:
global $wp_version;
ini_set('user_agent',apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ));
I tried all other answers here but for me, only adding
$mpdf->curlAllowUnsafeSslRequests = true;
fixed the issue.
I was running into the same issue. mPDF was running DOG SLOW and would end up just displaying a "Cannot find image file" error. After
checking to make sure the image is actually there
checking the permissions on the file
checking all of the error logs on the server
combing through the documentation on mPDF
I found that the image file in question was corrupted somehow. I downloaded the image to my local computer, opened it up with an image editor (Paint.NET in this case), re-saved it as a .gif file and uploaded it to the server again. That seemed to fix it. Your mileage my vary.
Also, for what its worth, I had to use images/image.gif instead of the file path /images/image.gif.
Just make sure that you have image related functions in your PDF class file. Like parsejpg, parsepng, parsegif etc...
I have password protected server (.htaccess / .passwd) and after some research I understand that mPDF using HTTP to get the images, but server blocks the images from the public because of password protection.
After removing password protection I had ssl certificate issue, and I enable usafe requests and it starts working
$mpdf->curlAllowUnsafeSslRequests = true;
Also you can always enable debug modes and follow the error messages
$mpdf->showImageErrors = true;
$mpdf->debug = true;

Can't open files generated by PHP app on windows

I'm having a problem when I try to open files that were generated by my CMS on my windows machine. It has an upload function that saves the file on a given location (it is on my user folder, where I'm supposed to have all the write and read permissions).
All I can see in that folder is a generic thumbnail, the ones generated by windows for each image type, PNGs and JPEGs in this case. I tried to change de image permissions and set it to the current computer user but it doesn't work. And I'm unable to move these files to another location (upload them to the server via FTP).
I wonder if there is a way to change this behavior.
One thing I noticed is that if I copy and paste those files, I can see its contents normally. I know I can do that to each of them and rename, but there are dozens of images in that folder... don't wanna do the same thing everytime I upload a new image.
Update
This is happening only to the images that were moved (I'm using php's move_uploaded_file function, btw), not to the ones that where generated (croped, resized and so on).
It`s happening because Windows keep file permissions of TEMP folder (usually c:/windows/temp) when moving a file.
To prevent it you need to change "upload_tmp_dir" in "php.ini" to your server directory or set wide permissions to your windows temp folder.
You probably have an error in some php file which is preventing the image from being displayed correctly.
What i would do in order to detect the problem is to comment out the header() calls in the php file responsible for displaying the image and see if there is any output other than the image data.
Inspect the whole output, it only takes a character to break everything, so check if there are no blank lines at the top or bottom of the output. And in case you have an error log, consult that, it will help you trace the problem quickly.
When i have this problem, it's usually a notice or a warning showing up during the process of the image generation, and if you haven't disabled errors from being output to the screen, the notice text will be considered as part of the image data which makes the browser unable to interpret your image.
If you'd like i can take a look closely for you but i would need to see what you are doing in that php file to be able to tell you for sure.

two sets of same php code with same version working differently on two different servers?

I made a class that converts a string of text into a png image and uploads on the server:
http://testing.mehhh.org/php/png.php (you can view php source on the page)
http://testing.mehhh.org/php/phg.php <-- shows php version
this one works great.
now I am trying to get this to work on a clients server
http://autoxplorer.com/~tameem/png.php This doesn't work!
http://autoxplorer.com/~tameem/php.php <-- also using same php version
what gives? I thought it's a permission thing.. but the png folder has full access.. and I tried a super simple uploading script and it runs and saves files to that folder. What is going on here?
You have just put online some PHP scripts that link to images. The link to the images actually is different.
http://testing.mehhh.org/php/png/4de9441d68cf8_1307132957.png
http://autoxplorer.com/~tameem/png/4de9424d41208_1307132493.png
While the first link returns actually an image, the second image link gives a 404 error. Looks like you have not configured your server properly to actually execute the PHP in the second case to return an image.

Categories