User tests: Successful: Unsuccessful:
Pull Request for Issue #46610
Modified modules/mod_custom/tmpl/default.php to dynamically prepend the site root URI to relative image paths in the custom module content using preg_replace. This ensures that src attributes pointing to local images (e.g., images/foo.jpg) are converted to absolute or root-relative paths (e.g., /joomla_root/images/foo.jpg), preventing broken images when the module is displayed on nested URLs.
When visiting a nested URL (e.g., site.com/group/page), the browser tries to resolve relative image paths relative to the current URL path (e.g., site.com/group/images/image.jpg). This results in a broken image link (404) because the image does not exist at that location.
The code intercepts the content and prepends the correct site root to the image src. The browser now consistently loads the image from the correct root path (e.g., site.com/images/image.jpg) regardless of how deep the current page URL is. The image displays correctly on all pages.
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Modules Front End |
Invalid PR, please close. Relative images are loaded respecting <base> HTML tag, please fix your template instead.
| Title |
|
||||||
| Title |
|
||||||
| Title |
|
||||||
| Title |
|
||||||
| Status | Pending | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-01-31 12:53:20 |
| Closed_By | ⇒ | tecpromotion | |
| Labels |
Added:
PR-6.0-dev
|
||
Thank you for your PR @KishoriBKarale
However, this is incorrect and will therefore be closed.
Testing with an existing article the image the image displayed correctly.
Ttesting with a a non-existent sub-URL (e.g., your-site.com/index.php/category/fake-page) the image is not rendered.
Applying the fix solved the problem
This is not the correct fix. You are fixing the problem in the wrong place as you are assuming that the problem is only with that module