Summary
On a few websites I’ve recently updated to MODX 2.8.1 (via sitedash) I’m experiencing a series of issues regarding media paths when adding images to contentblocks fields.
These websites are multicontext/multilanguage with Babel and XRouting.
The main language has path / while the others are set to use /en/ /it/ etc, the issue only appears on these.
The issue only seem to appear on modx 2.8+ and might also be related with upgrating SQL to version 5.7 on the hosting machine (this update caused a lot of issues on itself especially with the Gallery plugin).
Medias (both images or files) may or may not be called with a pthumb filter, doesnt seem to matter.
All the CB fields are setup to use a custom media source that points directly to assets/uploads/ to avoid the client’s access to the full filesystem
The issue seem to affect just media used in ContentBlocks, medias in normal TVs work as expected.
I have no idea how to tackle the situation.
Step to reproduce and Observed behavior
Case 1 - Visible error
In this is example i use a repeater with file, text and image fields, the image field automatically opens a crop selection.
- On a resource of the secondary context (/it/) i select from the media browser the image i already uploaded in the primary context (/)
- The automatic crop window opens and upon saving you get an error that the file path is not found. Important to notice that the path includes the context folder
- By ignoring the crop i can see the thumbnail in the backend but i get a broken image in the frontend.
- The error does not appear if the image is uploaded from scratch, crops goes fine. Obviosuly this creates a copy of the image on the server
- The path of the image is correct, but the file field path still shows the context folder.
Case 2 - Just the path error
In this example the CB field is just a simple image. No crops involved.
- Select the image from the media browser. Image is correctly shown in the backend but inspections shows the path with the added /en/ context folder
- Same thing in the frontend the image is shown but the path is wrong
Expected behavior
Context folder should not be added to the media path.
As an example on another site that uses the exact same configuration as the one of Case 2 but is still on MODX 2.7.2 the issues is nonexistent. Any media in any context is shows as the media source path starts from /assets/
Environment
MODX Revolution 2.8.1 - Apache server - MySQL 5.7
Tested on Firefox and Chrome
.htaccess file has the instruction:
# Redirect all requests from /xy/assets* to /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (en|fr|es|it|ru|cn|nl|de|)/assets(.*)$ /assets$2 [L,QSA]
allowing the images to be visible in the frontend.
On all the sites i’ve talked about the custom media source has these setting, i’ve tried to add/remove / or change to absolute path with no success: