Missing scheme when using an image that is inside a module

Created on 6 July 2023, over 1 year ago
Updated 4 August 2024, 4 months ago

When trying to use a local image from inside a module, a directory named ":" will be created and the resized image will be copied there. If there's no write permission to that directory, the following exception will be thrown.

Drupal\Core\Entity\EntityStorageException: The specified file 'modules/custom/my_module/images/logo.png' could not be copied because the destination directory '://resize' is not properly configured. This may be caused by a problem with file or directory permissions. in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 815 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

This is because the scheme is missing from $image['destination'].

Instead of returning an empty value for $path_info['scheme'] when the image's path doesn't match any stream wrapper, we can fallback to the default scheme.

🐛 Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024