User tests: Successful: Unsuccessful:
This PR improves the robustness of the Schemaorg plugin by ensuring that the image field is handled safely when provided as an array.
According to Schema.org specifications, the image property can be either a string or an array. While Joomla currently provides a single image via the UI, array values may be introduced by extensions, overrides, or future changes.
Previously, if an array was passed, it could lead to incorrect processing or unexpected behavior. This change ensures that such inputs are handled safely.
This update:
Temporarily simulate array input:
$itemSchema['image'] = [
'images/sample1.jpg',
'images/sample2.jpg'
];Verify:
None
This PR focuses on improving robustness and forward compatibility. It does not introduce any UI changes.
| Status | New | ⇒ | Pending |
| Category | ⇒ | Front End Plugins |
Test structured data with:
image as a string
image as an array of strings
how?
| Labels |
Added:
Feature
PR-6.2-dev
|
||
Hi @brianteeman,
Thank you for your question.
To test the changes:
Test cases:
Case 1:
"image": "images/sample.jpg"
Case 2:
"image": ["images/sample1.jpg", "images/sample2.jpg"]
Then check the generated structured data (JSON-LD) in the page source and verify:
I have also fixed the coding standard issues, so the CI checks should now pass.
Thank you!
Hi @richard67
Just a quick follow-up on this PR. All CI checks are now passing and the requested changes have been addressed.
Please let me know if anything else is needed.
Thank you!
All CI checks are now passing
@mohsinkhan85090 No, code style still fails. Please check ci checks on GitHub.
Please note that as you are a new contributor, a maintainer has to approve the CI workflow, so it may take some time until you can see failed checks.
I ask you again - how do I add multiple images to the schema as I cant see how to add anything more than a single image. I am obviously mising something as you have clearly added multiple images yourself or you could never have coded and tested this pull request
@mohsinkhan85090, I may not be as strong with Schemaorg plugin knowledge as I should be or thought, but just spent the last 20 minutes trying to figure out and trying different things unsuccessfully ;(
It would be swell / great if you could give specific Testing Instructions or perhaps a screen recording worse case of what you are doing so that testers can replicate it and then possibly pass the test for you :)
THANK YOU for your contribution and help.
Hi @brianteeman @exlemor @richard67
Thank you for your feedback, and I understand the confusion.
Currently, Joomla does not provide a UI to input multiple images for the schema directly. To test this feature, I simulated the input at code level.
Specifically, I modified the schema data before processing, for example:
$itemSchema['image'] = [
'images/sample1.jpg',
'images/sample2.jpg'
];
This allowed me to verify that:
For real-world use, this change ensures compatibility with Schema.org specifications where the "image" field can be an array (e.g., for products or rich results).
If needed, I can also provide a small test patch or example to help reproduce this more easily.
Additionally, I am fixing the remaining php-cs-fixer issues so that all CI checks pass.
Thank you for your patience and guidance!
All CI checks are passing and the requested changes have been addressed. The PR is ready for review whenever convenient.
ThankYou
Hi @brianteeman, @richard67, @exlemor
Thank you again for your patience
Since Joomla currently does not provide a UI to input multiple images for Schema.org, here is the simplest way to test this PR:
Apply this PR
Open file:
plugins/system/schemaorg/src/Extension/Schemaorg.php (or relevant file)
Temporarily add this before processing schema:
$itemSchema['image'] = [
'images/sample1.jpg',
'images/sample2.jpg'
];Load any article page
View Page Source → Check JSON-LD output
Thank you!
not for me to decide but this seems pointless to me. If there is no way for a user to add multiple images then the code in this pr will never be used
Hi @brianteeman, @richard67, @exlemor
Thank you for your feedback.
I understand that without UI support, the feature is not very useful in its current form. I am currently working on improving this by exploring a better way to make multiple image input usable through the UI.
Given the time constraints, I may not be able to complete a full UI implementation immediately, but I will continue working on this and update the PR accordingly.
I appreciate your guidance and feedback.
| Title |
|
||||||
Hi @brianteeman @muhme @richard67 @exlemor
I’ve updated the image handling logic to support multiple images and normalize inputs properly.
Please let me know if any changes are needed
| Title |
|
||||||
Hi @richard67,
I have created a new PR targeting the 6.2-dev branch as suggested.
The implementation has been cleaned up and now properly supports the image field as both string and array while preserving existing logic.
Please let me know if any further improvements are required.
Thank you!