spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
103 stars 29 forks source link

Exception during image generation not handled #241

Closed cstilstra closed 3 months ago

cstilstra commented 7 months ago

Bug description

I used the responsive image tag to try and display an image that was incorrect. The image had a .jpg extension but had it's mime type listed as png. Laravel's ImageGenerator correctly throws an exception, but that exception isn't handled anywhere in the tag so my entire page ends up crashing. What I would like to see is that information is written to the log and the responsive image tag displays nothing on the screen, rather than letting the exception go unhandled.

How to reproduce

In your OS, rename a .png file to .jpg without running through an actual image conversion function. Add this incorrect image to a Statamic project's assets. Then try to display this image on a Statamic page using the responsive image tag.

Logs

No response

Environment

Environment

Application Name: CMSBcom

Laravel Version: 10.48.4

PHP Version: 8.1.2-1ubuntu2.14

Composer Version: 2.5.4

Environment: local

Debug Mode: ENABLED

URL: cmsbcom.test

Maintenance Mode: OFF

Cache

Config: CACHED

Events: NOT CACHED

Routes: NOT CACHED

Views: CACHED

Drivers

Broadcasting: log

Cache: redis

Database: mysql

Logs: daily

Mail: smtp

Queue: sync

Session: file

Livewire

Livewire: v3.4.9

Statamic

Addons: 6

Antlers: runtime

Sites: 1

Stache Watcher: Disabled

Static Caching: half

Version: 4.55.0 PRO

Statamic Addons

jonassiewertsen/statamic-live-search: 2.0.1

jonassiewertsen/statamic-livewire: 3.2.0

spatie/statamic-responsive-images: 4.1.1

statamic-rad-pack/runway: 6.6.2

statamic/eloquent-driver: 3.3.2

statamic/seo-pro: 5.4.1

Statamic Eloquent Driver

Asset Containers: file

Assets: file

Blueprints: file

Collection Trees: file

Collections: file

Entries: eloquent

Forms: file

Global Sets: file

Global Variables: file

Navigation Trees: file

Navigations: file

Revisions: file

Taxonomies: file

Terms: file

Installation

Starter Kit using via CLI

Antlers Parser

regex (default)

Additional details

No response

stuartcusackie commented 7 months ago

I'm seeing a very similar problem. Asset images::7bnoix3p6r4ghrtgyvyqcipgr4.jpg.avif has 0 width or height. Cannot create responsive variants.

My client uploaded a weird looking image file: 7bnoix3p6r4ghrtgyvyqcipgr4.jpg.avif (note that it has two extensions - I don't know why!)

You can test this file if you want: https://easyupload.io/ogbna2

Simply add it to your entry and then try to generate a responsive image from it.

spatie-bot commented 3 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.