Can't use svg images because degov_auto_crop function calculateScaleFactor() runs into devision by zero error

Created on 15 March 2023, almost 2 years ago
Updated 20 July 2024, 8 months ago

Problem/Motivation

We in our agency would like to use svg images in a government project. But neither adding svg as an allowed image file format to media image nor creating a separate svg media type works. Unfortunately the module 'degov_auto_crop' public function calculateScaleFactor() runs in a division by zero error because $image_dimensions[0] is 0.

Steps to reproduce

We added media type 'svg' and configured the form display of the so handled content field to "image" or "entity browser" not the cropping mode. But always degov_auto_crop interferes when uploading an image in the content editor.

Proposed resolution

We would appreciate if the function calculateScaleFactor() would start with proving if the $image_dimension[0] is greater than 0. Like this:

    /**
     * if $image_dimensions[0] is not available (for instance with svg images) don't try to calculate it and return 1
     */
    if(!$image_dimensions[0]) return 1;

Alternatively we would like to know if there is a possibility to patch this behaviour using a composer patch. But unfortunately the module is part of a drupal profile and we don't know how to patch this or how to override it using a module.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs work

Version

9.2

Component

Code

Created by

🇩🇪Germany henrik23

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

Comments & Activities

Production build 0.71.5 2024