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

Made template for showing image_field in admin-ui more robust #1387

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

vidarl
Copy link
Contributor

@vidarl vidarl commented Oct 31, 2024

Description:

I was not able to reproduce the problem on a fresh 4.6, but on a installation just upgraded to 4.6 (was at some point using 2.5 or maybe even older releases) the database had a lot of images with the following "empty" data in ezcontentobject_attribute.data_text:

<?xml version="1.0" encoding="UTF-8"?>
<ezimage serial_number=""
         is_valid=""
         filename=""
         suffix=""
         basename=""
         dirpath=""
         url=""
         original_filename=""
         mime_type=""
         width=""
         height=""
         alternative_text=""
         alias_key="1293033771"
         timestamp="1086942459" />

In 4.6, the value will simply be null if no image is uploaded. However, in earlier versions it was obviously stored like shown above. And one problem here is that height has a value set to empty string. The admin-ui template requires height to be numeric or a Unsupported operand types: string / string exception will be thrown.

It would be nice if twig had a is numeric test but that is not going to happend. For this use-case it is sufficient to check if value is empty string too

For QA:

Documentation:

Copy link

…content_fields.html.twig

Co-authored-by: Paweł Niedzielski <[email protected]>
@vidarl vidarl requested a review from Steveb-p December 17, 2024 13:49
@vidarl
Copy link
Contributor Author

vidarl commented Dec 18, 2024

@ViniTou or anyone... Is QA really needed for this PR ?

@ViniTou
Copy link
Contributor

ViniTou commented Dec 18, 2024

@vidarl
We decided to skip it, I will merge it up.

@ViniTou ViniTou merged commit 4ae54ca into 4.6 Dec 18, 2024
29 checks passed
@ViniTou ViniTou deleted the make_ezimage_field_more_robust branch December 18, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants