liip / liip/LiipImagineBundle

Default image when filter fails

Open
#1,622 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.7k
Forks
386
Avg merge
1d 10h
Merged PRs (30d)
3

Description

Probably this is already possible, but i did not find it in documentation.
Problem:
Users can upload data: images, PDF documents, videos.
After upload, i try to show a thumbnail of the image. This works well for images and PDF files (most of the time), but not for videos.
I tried to set a "default_image" in the filter, but this does not help. My guess is, that default_image only works if the file is not found, but when the image processor cannot generate a image - what then?
default_image parameter is not documented at all. So just guessing here!

Here is my config:

```
liip_imagine:
twig:
mode: "lazy"
# valid drivers options include "gd" or "gmagick" or "imagick"
driver: "imagick"
# configure data loaders
loaders:
# sql_binary_data_loader:
uploads:
filesystem:
data-root: '%app.upload-dir%'
allow_unresolvable_data_roots: true
# chain:
# chain:
# loaders:
# - sql
# - uploads
resolvers:
upload_thumbs:
web_path: ~
# configure custom data loader as default
data_loader: sql_binary_data_loader
# configure cache resolvers
cache: sql_binary_cache
# your filter sets are defined here
filter_sets:
# the name of the "filter set"
sql_thumb:
# adjust the image quality to 75%
quality: 75
# generate jpeg
format: jpeg
# list of transformations to apply (the "filters")
filters:
thumbnail:
size: [120, 120]
mode: inset
allow_upscale: true
background:
color: '#ffffff'
upload_thumb:
default_image: "images/thumbnail-dummy.png"
data_loader: uploads
cache: upload_thumbs
# adjust the image quality to 75%
quality: 75
# generate jpeg
format: jpeg
# list of transformations to apply (the "filters")
filters:
thumbnail:
size: [120, 120]
mode: inset
allow_upscale: true
background:
color: '#ffffff'

```

The sql loader and cache things just put the images in sql - not my intention, it was a requirement - dont ask.

In Twig (live component):
```php
{% trans %}Preview not available{% endtrans %}
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the imagine_filter entry point shown in the Twig snippet and the upload_thumb filter-set configuration, then trace how default_image is handled when source processing fails. Compare missing-file and unsupported-video cases; done means the fallback behavior is defined and verified, with the default_image option documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, symfony
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.