joomla-cms
joomla-cms copied to clipboard
Schema image paths missing forward slash
Steps to reproduce the issue
Add article to a Category Blog
View HTML
Relevant line starts with script type="application/ld+json">{"@context":"https://schema.org","@graph":
Expected result
Relative path for schema "image" and "thumbnailUrl" includes forward slash so the relative path points to root and therefore domain/images
Actual result
Forward slash missing from schema "image" and "thumbnailUrl" resulting in relative path pointing to category and therefore non-existent domain/blog/images
System information (as much as possible)
Present in Joomla 5.1.2 and 5.1.3
Additional comments
Issue confirmed (5.2).
quick research: all urls should be absolute in schema ld see this stackoverflow solution and linked ressources: stackoverflow
Issue confirmed. See these test results. Google reports no problems but it also has the WRONG path to the image
I am not submitting a PR because
- I am not 100% certain of everywhere that this needs to be fixed
- The schemaorg cache needs to be invalidated before you will see any changes and I dont know how to do that
However the basic fix is to change the code so that the uri root is prepended to the image.
Example
$schema['thumbnailUrl'] = HTMLHelper::_('cleanImageUrl', $article->images->get('image_intro'))->url;
Should be changed to
$schema['thumbnailUrl'] = Uri::root() . HTMLHelper::_('cleanImageUrl', $article->images->get('image_intro'))->url;
Clean Cache
I think the code for this would be
Factory::getCache()->clean('schemaorg');
I think that every single occurence of
HTMLHelper::_('cleanImageUrl'
has to be changed as we don't allow to add images from external sources. (not 100% sure)
cleanimageurl says it supports absolute image paths as well as relative ones but I dont see how
Hi. I noticed this by checking the “System - Redirect” page where I found several lines reporting a 404 for some images. Checking the page source I saw that the 404s were related to schema.org JSON
For those inserted by me I solved by simply typing the absolute URL... for those inserted by Joomla as “default” (e.g logo of the web site for Person item) I had to display hidden fields in the “schema.org” tab of the articles and set an absolute path for those as well.
Closing as having a pull request. Please test #46306 . Thanks in advance.