joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

Schema image paths missing forward slash

Open QuotesUK opened this issue 1 year ago • 1 comments

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

schema

QuotesUK avatar Aug 21 '24 10:08 QuotesUK

Issue confirmed (5.2).

ghost avatar Aug 27 '24 12:08 ghost

quick research: all urls should be absolute in schema ld see this stackoverflow solution and linked ressources: stackoverflow

marcorensch avatar Feb 05 '25 20:02 marcorensch

Issue confirmed. See these test results. Google reports no problems but it also has the WRONG path to the image

Image

brianteeman avatar Feb 05 '25 22:02 brianteeman

I am not submitting a PR because

  1. I am not 100% certain of everywhere that this needs to be fixed
  2. 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');

brianteeman avatar Feb 06 '25 11:02 brianteeman

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)

chmst avatar Feb 06 '25 12:02 chmst

cleanimageurl says it supports absolute image paths as well as relative ones but I dont see how

brianteeman avatar Feb 06 '25 14:02 brianteeman

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.

luX0r-reload avatar Mar 21 '25 12:03 luX0r-reload

Closing as having a pull request. Please test #46306 . Thanks in advance.

richard67 avatar Oct 17 '25 07:10 richard67