Worklog for task "Проработать редиректы"
Now there's a big mess with image paths.
When you select images in TV fields, it saves the relative path from the root of the media source itself, not from the site root. For example, the full path is: /userfiles/Dopolnitelnoe_oborydovanie/balka-s-kachelyami-i-kolczami-samson.png and it saves Dopolnitelnoe_oborydovanie/balka-s-kachelyami-i-kolczami-samson.png
MODX logic: "What's the big deal? Default media source, take it from there."
The fact that the default media source can be changed (and it was changed) doesn't concern them. As a result, the image on the frontend is currently held up by the phpthumb cache, but is not accessible via a direct link.
As a result, we had to put a makeshift workaround in the resizer
// Searching for a file with alternative prefixes for old images
if (!fs.existsSync(absPath)) {
const altPrefixes = ['images_old/', 'userfiles/', 'images_old/userfiles/']
for (const prefix of altPrefixes) {
const altPath = resolve(`/uploads/`, prefix + src)
const altAbsPath = process.cwd() + altPath
if (fs.existsSync(altAbsPath)) {
absPath = altAbsPath
break
}
}
}
But we will also need to excise the images_old prefix from the URLs, and for that, we will probably have to set up redirects as well.