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

Linking a SVG image in markdown: error #37

Open
aleclerc7 opened this issue Apr 1, 2022 · 0 comments
Open

Linking a SVG image in markdown: error #37

aleclerc7 opened this issue Apr 1, 2022 · 0 comments

Comments

@aleclerc7
Copy link

aleclerc7 commented Apr 1, 2022

Hello,

Linking a SVG image in markdown is not working:

[![](image.svg)](https/external/link)

This lead to an error:

/config/www/user/plugins/external_links/classes/ExternalLinks.php
Arguments
"Trying to access array offset on value of type bool"

Code (line 294):

        $width = 0;
        $height = 0;
 
        // Determine image dimensions based on "src" atrribute
        if ($imgNode->hasAttribute('src')) {
            $src = $imgNode->getAttribute('src');
 
            // Simple check if the URL is internal i.e. check if path exists
            $path = $_SERVER['DOCUMENT_ROOT'] . $src;
            if (realpath($path) && is_file($path)) {
                $size = @getimagesize($path);
            } else {
                // The URL is external; try to load it (default: 32 KB)
                $size = $this->getRemoteImageSize($src, $limit * 1024);
            }
        }
 
        // Read out width and height from <img> attributes
        $width = $imgNode->hasAttribute('width') ?
            $imgNode->getAttribute('width')  : $size[0];  <<<<<<<<<<<<<<<<<< ERROR
        $height = $imgNode->hasAttribute('height') ?
            $imgNode->getAttribute('height')  : $size[1];
 
        // Get width and height from style attribute
        if ( $imgNode->hasAttribute('style') ) {
            $style = $imgNode->getAttribute('style');
 
            // Width
            if (preg_match('~width:\s*(\d+)([a-z]+)~i', $style, $matches)) {
                $width = $matches[1];
                // Convert unit to pixel
                if ( isset($units[$matches[2]]) ) {
                    $width *= $units[$matches[2]];
                }
            }
 
            // Height
            if (preg_match('~height:\s*(\d+)([a-z]+)~i', $style, $matches)) {
                $height = $matches[1];
                // Convert unit to pixel

Kind regards

@aleclerc7 aleclerc7 changed the title Linking an image in markdown: error Linking a SVG image in markdown: error Apr 1, 2022
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

No branches or pull requests

1 participant