• Resolved simkog

    (@simkog)


    Dear Developer,

    I’ve found a strange bug on one of our websites that uses your plugin to support SVG files.

    We used some older versions of your Safe SVG plugin to upload SVG files to the website. I think it had a bug, the image’s metadata is not generated properly, so some required meta is missing from the SVG images.

    Some plugins and themes are using this metadata for various functions, and without them, the log file is filled with undefined index notices.

    I’ve tried an older version of your plugin (1.5.0 in this test) on a staging site, and I could replicate this bug! Although, it did not occur in the newer versions of the plugin.

    BUT! I could not regenerate these metadata for the previously uploaded SVG pictures. How can I update these old SVG images without uploading them again?

    Example old uploaded image metadata (using wp_get_attachment_metadata() function):

    Array
    (
        [filesize] => 12313
    )

    Same image uploaded with the latest version on the plugin:

    Array
    (
        [width] => 1405
        [height] => 256
        [file] => 2022/09/televitamin-logo-wide-simple.svg
        [sizes] => Array
            (
                [thumbnail] => Array
                    (
                        [width] => 150
                        [height] => 150
                        [crop] => 1
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
                [medium] => Array
                    (
                        [width] => 300
                        [height] => 300
                        [crop] => 
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
                [medium_large] => Array
                    (
                        [width] => 768
                        [height] => 0
                        [crop] => 
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
                [large] => Array
                    (
                        [width] => 1024
                        [height] => 1024
                        [crop] => 
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
                [1536x1536] => Array
                    (
                        [width] => 1536
                        [height] => 1536
                        [crop] => 0
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
                [2048x2048] => Array
                    (
                        [width] => 2048
                        [height] => 2048
                        [crop] => 0
                        [file] => televitamin-logo-wide-simple.svg
                        [mime-type] => image/svg+xml
                    )
    
            )
    
    )
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Darin Kotter

    (@dkotter)

    @simkog Thanks for the question. You mention that some image metadata is missing, causing some undefined errors. Could you provide an example of an error you’re seeing?

    Thread Starter simkog

    (@simkog)

    Dear @dkotter,

    Yes, of course! This is an error log entry from one of our websites.

    [03-Sep-2022 10:45:20 UTC] PHP Notice: Undefined index: file in /***domain***/wp-includes/media.php on line 1676

    You can see in my previous comment, that the file index is missing from the array when the image was uploaded with the older version of the plugin.

    Plugin Support Darin Kotter

    (@dkotter)

    @simkog Thanks! Do you know which older version of Safe SVG you were using? Curious to track down when/why that meta wasn’t being created properly.

    We don’t have a way within this plugin though to fix that. I’d suggest either using the Regenerate Thumbnails plugin or if you have access to WP CLI, using the regenerate command.

    Thread Starter simkog

    (@simkog)

    @dkotter I did not remember the exact version. I would say the version before you changed the plugin’s icon.

    For the Regenerate Thumbnails plugin: I’ve tried it, and it fails because of the missing metadata.

    Plugin Support Darin Kotter

    (@dkotter)

    Have you tried regenerating all images? I don’t believe it will work if you try and regenerate the individual SVGs

    Thread Starter simkog

    (@simkog)

    @dkotter Tried that too, same error.

    But, I’ve found a solution.

    There is a plugin (Enable Media Replace by ShortPixel) which allows the user to upload a new version of an image. With this plugin, when I replace the problematic image with the same image again, the metadata will be fixed for the correct scheme.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Missing metadata for old uploaded SVG images’ is closed to new replies.