Gallery thumbnails broken in manager

Gallery thumbnails broken in manager the connector URL appears to be double-encoding

MODX 2.8.7 + PHP 8.1 + Latest Gallery Plugin

I browse the gallery via modx manager for example when adding an image TV to a page.

Images exist in the correct /assets/gallery/ folder.
File permissions are correct and thumbnails for other parts of the site work fine.
Direct calls to the Gallery connector like this generate thumbnails correctly:

https://www.example.com/assets/components/gallery/connector.php?action=web/phpthumb&ctx=mgr&src=/assets/gallery/9/52.jpg

the actual call looks like this:

https://www.example.com/assets/components/gallery/connector.php?action=web/phpthumb&ctx=mgr&src=%2Fassets%2Fgallery%2F9%2F52.jpg

which doens’t display an image.

Error log:
[2025-06-28 07:45:15] (ERROR @ /var/www/clients/client1/web1/web/core/components/gallery/processors/web/phpthumb.class.php : 181) [phpThumbOf] Could not generate thumbnail: /var/www/clients/client1/web1/web/ - Debug: Array
(
[0] => phpThumb() v1.7.22-202312071641 in file “phpthumb.class.php” on line 279
[1] => setSourceFilename(/var/www/clients/client1/web1/web/) set $this->sourceFilename to “/var/www/clients/client1/web1/web/” in file “phpthumb.class.php” on line 347
[2] => CleanUpCacheDirectory() set to purge (NULL days; NULL MB; NULL files) in file “phpthumb.class.php” on line 806
[3] => CleanUpCacheDirectory() skipped because “/var/www/clients/client1/web1/web/assets/components/gallery/cache//phpThumbCacheStats.txt” is recently modified in file “phpthumb.class.php” on line 816
[4] => $AvailableImageOutputFormats = array(text;ico;bmp;wbmp;gif;avif;webp;png;jpeg) in file “phpthumb.class.php” on line 1071
[5] => $this->thumbnailFormat set to $this->config_output_format “jpeg” in file “phpthumb.class.php” on line 1083
[6] => $this->thumbnailFormat set to $this->f “jpeg” in file “phpthumb.class.php” on line 1090
[7] => $this->thumbnailQuality set to “75” in file “phpthumb.class.php” on line 1100
[8] => resolvePath: /var/www/clients/client1/web1/web/ (allowed_dirs: Array
(
)
) in file “phpthumb.class.php” on line 1243
[9] => resolvePath: iteration, path=/var/www/clients/client1/web1/web/, base path = /var/www/clients/client1/web1/web in file “phpthumb.class.php” on line 1262
[10] => open_basedir: “/var/www/clients/client1/web1/web:/var/www/clients/client1/web1/private:/var/www/clients/client1/web1/tmp:/var/www/boltonfm.com/web:/srv/www/boltonfm.com/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/dev/random:/dev/urandom” in file “phpthumb.class.php” on line 1229
[11] => resolvePath: stop at component 8 in file “phpthumb.class.php” on line 1278
[12] => resolvePath: stop at path=/var/www/clients/client1/web1/web in file “phpthumb.class.php” on line 1281
[13] => resolvePath: path parsed, over in file “phpthumb.class.php” on line 1287
[14] => $this->sourceFilename set to “/var/www/clients/client1/web1/web” in file “phpthumb.class.php” on line 988
[15] => phpThumb() v1.7.22-202312071641

Error messages disabled.

Am I doing something wrong?

I assume I can ignore the open base dir error - never did figure that one out, but it’s doesn’t stop phpThumb working elsewhere on the site.

Don’t know how long it’s been like that, to be honest don’t use it very often, browsing with the actually galley plugin works fine.

Thanks In advance.

Does this issue only happen if you use a certain media source?

Or asked differently, if you open “Media” → “Media Browser” (in the top menu) and navigate to the assets/gallery/ folder in the default “Filesystem” Media Source, do the thumbnails show then?

That does work, images are shown correctly. Completely different load method appears to be used. No double &

I have changed the auth element - assuming that could be security sensitive.
/connectors/system/phpthumb.php?src=assets%2Fgallery%2F16%2F389.jpg&w=100&h=0&HTTP_MODAUTH=********************************************&f=png&q=90&wctx=mgr&source=1&t=1643532497

It’s an old installation (which has been upgraded through the versions) have I got some legacy code somewhere.

The Gallery extra comes with a custom media-source type.

Can you confirm that this custom media-source type (= “Gallery Albums”) is used (for the media-source with the broken thumbnails)?
To verify, go to “Media” → “Media Sources” in the top-menu → right-click the media-source in question → select “Update Media Source” → check if the value of the “Source Type:” dropdown is “Gallery Albums”).

It is set to Gallery Albums

OK. So I found the code that does it in core/components/gallery/model/gallery/galitem.class.php

$url = $value.'&'.http_build_query($format,'','&');
if ($this->xpdo->getOption('xhtml_urls',null,false)) {
    $value = str_replace('&','&',$url);
    $value = str_replace('&','&',$value);
} else {
    $value = $url;
}

The system setting “xhtml_urls” was set to true so I changed it to false and that fixed the issue in manager. Thumbnails are now correctly generated.

Is that going to break something elsewhere?

Have I got outdated code?

Is the default for “xhtml_urls” now false so it wouldn’t be a problem with new installs?

The system setting xhtml_urls is a setting of the MODX core (and not a setting of the Gallery extra) and the default value is Yes. So changing this setting might affect other code on your site, especially when URLs are generated.


It think the cause of the issue is, that (like 5 years ago) the Javascript code of the MODX media browser got changed, to encode HTML in the URLs (for security reasons). Because the media-source of the Gallery extra already encodes the & in URLs on the server (in PHP), it’s now encoded twice.

I guess, the code in the Gallery extra has to be changed to account for this.

Where does that get reported then? It is a bug in the Gallery extra.
I have reverted my change - it may introduce security risks.

I’ve created a pull request on Github that should fix the issue:

(It’s not the most elegant solution, but this feature of the extra is hardly ever used.)

For MODX 2.x, only the change to core/components/gallery/model/gallery/galleryalbumsmediasource.class.php is relevant.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.