You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I installed the Gregwar/Image package ( https://github.com/Gregwar/Image ) to laravel, I changed the caching directory to $cacheDir = '/public/cache/images/';, I can generate cached image in php artisan tinker, but when I use it in blade template or controller I get the http://localhost/testsite/public/cache/images//f/a/l/l/b/fallback.jpg error url instead, I have narrowed down the problem to: Gregwar\Image\Adapter\GD and this function:
protected function openJpeg($file)
{
if (file_exists($file) && filesize($file)) {
$this->resource = @imagecreatefromjpeg($file);
} else {
$this->resource = false;
}
}
the code inside if (file_exists($file) && filesize($file)) { never runs and filesize() returns NOTHING using print_r or dd(), I have no idea how to fix this, the weird thing is it works in php artisan tinker but NOT on the actual site
The text was updated successfully, but these errors were encountered:
If you get the fallback it's cos gregwar can't find the file.
You should try to use absolute paths always. The Laravel public_path() helper may help you here, or base_path(), depending on where your images are on your server.
You will also get the fallback image if the jpeg is unable to be opened but still exists. If you comment out the try/catch statement here, you will see what error is causing the package to be unable to open jpegs. In my case, I did not have gd properly installed.
I installed the Gregwar/Image package ( https://github.com/Gregwar/Image ) to laravel, I changed the caching directory to
$cacheDir = '/public/cache/images/';
, I can generate cached image inphp artisan tinker
, but when I use it in blade template or controller I get thehttp://localhost/testsite/public/cache/images//f/a/l/l/b/fallback.jpg
error url instead, I have narrowed down the problem to:Gregwar\Image\Adapter\GD
and this function:code used in blade:
the code inside
if (file_exists($file) && filesize($file)) {
never runs andfilesize()
returns NOTHING usingprint_r
ordd()
, I have no idea how to fix this, the weird thing is it works inphp artisan tinker
but NOT on the actual siteThe text was updated successfully, but these errors were encountered: