Paragraphs icon file size restriction

Created on 5 September 2024, 6 months ago

I have been trying to find any similar issue to this without success. I can not believe that I am the only person to have noticed this so could a kind maintainer please redirect me if necessary?

Problem/Motivation

The Drupal Paragraphs module permits the addition of an icon image file. It would appear that there is no file restriction on this icon file size which can cause a problem since the icon is then embedded into the config code under 'icon_default'. This has been surfaced where screenshots had been used as icon files without realising that the files had been exported to the configuration files sizes exceeding 4.096Mb and thus affecting any configuration management actions.

Steps to reproduce

Install paragraphs modules
Navigate to Structure > Paragraphs
Create a new paragraph
Add a title
Add an icon
Save
Export the configuration of that created paragraph and you will see that the icon is now embedded in code.

Proposed resolution

Place an image size restriction on the image upload field

Feature request
Status

Active

Version

1.18

Component

Code

Created by

🇬🇧United Kingdom macjules London, West Oxfordshire

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @macjules
  • 🇧🇪Belgium dieterholvoet Brussels

    This is a pretty serious issue. We have had this happen on a couple projects, someone uploading a big image, and every time it takes down the whole site after we deploy these changes. We get the following error:

    SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

    It seems like the only way to recover is to manually edit the paragraph type entries in the config table, not even a cache rebuild or config import works.

  • 🇧🇪Belgium dieterholvoet Brussels

    I just checked and in Gin, with the Paragraphs EE modal browser, the icon is displayed as a 172x106 image. If we double that (accounting for retina displays) and feed it into this Image File Size Calculator, it gives us an average file size of 0.2188MB. I think a max image size of 0.5MB should be plenty, especially since with the default Paragraphs module icons are displayed a lot smaller. If someone needs more, they can still alter the form.

  • Merge request !167Resolve #3472308 "Paragraphs icon file" → (Open) created by dieterholvoet
  • 🇧🇪Belgium dieterholvoet Brussels

    Here's a patch that's compatible with core versions below 10.2.0, for use with composer-patches.

  • Pipeline finished with Success
    about 2 months ago
    Total: 487s
    #390842
  • 🇨🇭Switzerland berdir Switzerland

    Instead of a filesize, it's also possible to set size restrictions and it will automatically resize it. That said, how big the icon is displayed can easily be adjusted by custom sizes, ours are considerably larger than the default.

Production build 0.71.5 2024