Skip to content

Media renaming causes issues #77

Description

@3e33
Image

The little renaming icon lets you rename the file. Two issues here:

  1. Adding a space in the name will break Markdown, which doesn't allow spaces in the URL ![Image Text](media://Test Image.jpg) will not work and show the unprocessed markdown on the page.
  2. Renaming will not add the file extension, if you rename to just TestImage, then the file will also be TestImage, and if you try to use this inside Markdown without an extension, Grav throws an error. Actually any links without an extension will throw.
    ![Image Text](media://anythinghere) <-- this throws:
call_user_func_array(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object

/system/src/Grav/Common/Page/Markdown/Excerpts.php

                if (array_search($method, array_column($actions, 'method')) === false) {
                    $actions[] = [
                        'method' => $method,
                        'params' => $params,
                    ];
                }
            }
        }
 
        // loop through actions for the image and call them
        foreach ($actions as $action) {
            $matches = [];
 
            if (preg_match('/\[(.*)\]/', (string) $action['params'], $matches)) {
                $args = [explode(',', $matches[1])];
            } else {
                $args = explode(',', (string) $action['params']);
            }
 
            $medium = call_user_func_array([$medium, $action['method']], $args);
        }
 
        if (isset($url_parts['fragment'])) {
            $medium->urlHash($url_parts['fragment']);
        }
 
        return $medium;
    }
 
    /**

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions