Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images too large for thumbnail generation look like failed uploads #11228

Open
daun opened this issue Dec 6, 2024 · 2 comments
Open

Images too large for thumbnail generation look like failed uploads #11228

daun opened this issue Dec 6, 2024 · 2 comments
Labels

Comments

@daun
Copy link
Contributor

daun commented Dec 6, 2024

Bug description

Images larger than assets.thumbnails.max_width won't generate thumbnails, which is fine, but to non-technical editors that don't know this limitation, it looks like the image is broken or there was an error uploading it. The thumbnail url resolves to a 404 and will prompt the browser to show an icon for broken/missing images.

Example

Screenshot 2024-12-06 at 21 18 04

Suggested solution

I'd suggest showing a generic "image" icon instead of linking to the thumbnail here, similar to how non-image assets are displayed, e.g. PDFs that have their own icon.

Screenshot 2024-12-06 at 21 25 19

How to reproduce

Upload than image larger than 10.000 x 10.000px

Logs

No response

Environment

Environment
Application Name: *****
Laravel Version: 11.30.0
PHP Version: 8.3.14
Composer Version: 2.8.3
Environment: development
Debug Mode: ENABLED
URL: *****.test
Maintenance Mode: OFF
Timezone: Europe/Vienna
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.37.0 PRO

Statamic Addons
daun/statamic-widget-collection-count: 1.3.0
doefom/statamic-export: 0.4.0
jacksleight/statamic-bard-mutator: 3.0.3
jacksleight/statamic-bard-texstyle: 3.3.2

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

@daun
Copy link
Contributor Author

daun commented Dec 6, 2024

Looking at the source, there is some logic for showing a placeholder instead of the thumbnail.

class ThumbnailController extends Controller
{
    /**
     * If an image is deemed too large for thumbnail generation, we'll give it a placeholder icon.
     */
    private function getPlaceholderResponse()
    {
        $maxWidth = Config::get('statamic.assets.thumbnails.max_width');
        $maxHeight = Config::get('statamic.assets.thumbnails.max_height');

        if ($this->asset->width() < $maxWidth && $this->asset->height() < $maxHeight) {
            return;
        }

        return redirect(Statamic::cpAssetUrl('svg/filetypes/picture.svg'));
    }
}

@daun
Copy link
Contributor Author

daun commented Dec 6, 2024

The logic is working correctly, redirecting to the placeholder SVG. However it looks like those SVGs at vendor/statamic/svg/filetypes/* are currently not copied into the final build folder. They're probably all dynamic JS imports these days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants