Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
Thank you for this module. Why not add a markup for images to the sitemap ?
https://support.google.com/webmasters/answer/178636?hl=en
No Sitemap module can do this.
Comment | File | Size | Author |
---|---|---|---|
#3 | add-images-to-sitemap-2903165-3.patch | 11.18 KB | Maico de Jong |
|
Comments
Comment #2
gbyte CreditAttribution: gbyte as a volunteer and commentedInteresting idea, should be doable as files store which entities they are attached to. Wondering if there is an easy API way of doing this or if entityQuery is the way. There should be a way of toggling this on and of and hte code should be implemented somewhere inside
UrlGeneratorBase::addUrlVariants()
.This is not a priority right now, but I am happy to review and commit patches.
Comment #3
Maico de JongWould be great if this is added to the module, for a site i am currently migrating from D7 to D8 i previously used a xmlsitemap hook for this.
Attached patch adds an 'Include images' checkbox on the entity(type) Simple Sitemap form. It uses the file_usage table for adding the image urls to the sitemap. Not sure if this is the the way to go, but it should be faster/simpler then looping through all entity fields looking for referenced images.
Comment #5
gbyte CreditAttribution: gbyte as a volunteer and commentedThanks @MDJ Webdiensten, function wise your patch is very well written. I took the liberty of cleaning it up, fixing some inconsistencies and adding some javascript magic.
Next we should add tests for images and update documentation and readme.
Maybe we should also add an option to the custom link form where one can check if images are to be included, as custom links can be canoncial entities with referenced images. Version 2.10 of this module will bring lots of great stuff!
Comment #6
zenimagine CreditAttribution: zenimagine commentedthank you for your work, I will test it
Comment #7
gbyte CreditAttribution: gbyte as a volunteer and commented@zenimagine Please test and report back.
Another thing that just came to my mind is if it is alright that we include the link to the full image instead of the derived image style linked in the entity view. This is the one would usually have access to. Huge original images looked up by many bots could put a load on the server. What do you think guys?
Comment #8
zenimagine CreditAttribution: zenimagine commentedthe update to the dev version creates a database error
TypeError: Argument 2 passed to Drupal\simple_sitemap\EntityHelper::__construct() must be an instance of Drupal\Core\Database\Connection, none given, called in /home/www.domaine.com/public_html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 268 in Drupal\simple_sitemap\EntityHelper->__construct()
Comment #9
gbyte CreditAttribution: gbyte as a volunteer and commented@zenimagine You probably haven't run /update.php after the update.
Comment #10
zenimagine CreditAttribution: zenimagine commentedThank you, it works.
I tested the picture and it's really great ;-)
Maybe you could also integrate this :
https://developers.google.com/webmasters/videosearch/sitemaps
https://support.google.com/webmasters/answer/74288?hl=en
Another thing would be to separate the sitemaps by entity type.
In this way we could have several sitemaps in Google webmaster tools.
This allows to see the part of the site not well indexed.
Comment #11
zenimagine CreditAttribution: zenimagine commentedAn option for the administrator to select the image style to index would be great.
Comment #12
gbyte CreditAttribution: gbyte as a volunteer and commented@zenimagine Please create separate issues for things like video search. Regarding separating sitemaps by entity type, there is already an issue here: #2652696: Different contexts of sitemap.xml
I don't know if this would be the right approach. Option where? In settings or on bundle level? Wouldn't it be better if the file style from the canonical entity view would be automatically taken?
Comment #13
Maico de Jong@gbyte.co Thanks for adding this feature!
What do you mean with the 'canonical entity view': Use the image style as defined in the full (or default) entity display? Not sure how that will work, images could also be formatted by different formatters(slideshow, colorbox, url etc.)
We also have to keep in mind that images can come from multiple image fields which all could have different dimensions or styles to use, so adding an option for the administrator would become a complex solution. Maybe images used in textfields are even included now since we are just looking images up in the file_usage table.
Comment #14
gbyte CreditAttribution: gbyte as a volunteer and commented@MDJ Webdiensten I meant getting the image style from the default Drupal image field + Default view mode. If we can't get any, we could fall back to the original image URI from the file_managed table.
I spent some time trying to get the style of an image attached to an entity by using
entityTypeManager()->getStorage('entity_view_display')->load()
. There seem to b no API functions to do this. I will look into it in the future in case this becomes a widely needed feature, closing this for now.Comment #16
FiNeX CreditAttribution: FiNeX as a volunteer commentedHi, I'm currently using the media module to attach images on nodes (or paragraphs). This means the current implementation cannot get the images used on nodes. Would be possible to recursively search the images through referenced entities?
Comment #17
gbyte CreditAttribution: gbyte as a volunteer and commentedI am not entirely happy with the current implementation of image indexation in this module and would like to find a better way to do this. I understand since Drupal 8.4 media is part of core, so we certainly should look into utilizing it to index images. However I am not yet educated on how the new core media module works, so patches and input are appreciated. Feel free to create a feature request.
Comment #18
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commented