craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

[4.x]: Image editor doesn't work for filesystems without URLs #11687

Closed mmikkel closed 2 years ago

mmikkel commented 2 years ago

What happened?

Description

This is likely related to #11686 as it seems like the same underlying error occurring:

When opening the image editor, either via the element index action "Edit Image" or via the "Edit" button on top of the image thumbnail in slideouts and edit pages, the image editor opens but the image never loads. There is no visible error message, but the browser's dev tools console reveals a 500 error from the assets/edit-image action, with the following exception:

TypeError: craft\services\Assets::getImagePreviewUrl(): Return value must be of type string, null returned in /path/to/project/vendor/craftcms/cms/src/services/Assets.php:669
Stack trace:
#0 /path/to/project/vendor/craftcms/cms/src/controllers/AssetsController.php(816): craft\services\Assets->getImagePreviewUrl(Object(craft\elements\Asset), 2622, 2622)
#1 [internal function]: craft\controllers\AssetsController->actionEditImage()
#2 /path/to/project/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#3 /path/to/project/vendor/yiisoft/yii2/base/Controller.php(178): yii\base\InlineAction->runWithParams(Array)
#4 /path/to/project/vendor/yiisoft/yii2/base/Module.php(552): yii\base\Controller->runAction('edit-image', Array)
#5 /path/to/project/vendor/craftcms/cms/src/web/Application.php(301): yii\base\Module->runAction('assets/edit-ima...', Array)
#6 /path/to/project/vendor/craftcms/cms/src/web/Application.php(625): craft\web\Application->runAction('assets/edit-ima...', Array)
#7 /path/to/project/vendor/craftcms/cms/src/web/Application.php(280): craft\web\Application->_processActionRequest(Object(craft\web\Request))
#8 /path/to/project/vendor/yiisoft/yii2/base/Application.php(384): craft\web\Application->handleRequest(Object(craft\web\Request))
#9 /path/to/project/web/index.php(12): yii\base\Application->run()

Steps to reproduce

  1. Create a volume, and attach a filesystem with the "Files in this filesystem have public URLs" setting disabled to it
  2. Upload an image to the volume
  3. Open the image editor for the image, either from the assets element index action "Edit Image" or via the "Edit" button in the slideout or edit page

Expected behavior

Image editing fun.

Actual behavior

No fun.

Craft CMS version

4.1.4.1

PHP version

8.1.8

Operating system and version

macOS 12.4, Edge 103.0.1264.62 (Official build) (arm64)

Database type and version

MariaDB 10.8.3

Image driver and version

Imagick 3.7.0 (ImageMagick 7.1.0-29)

Installed plugins and versions

None

brandonkelly commented 2 years ago

This is fixed alongside #11686 for the next release!