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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zenimagine created an issue. See original summary.

gbyte’s picture

Priority: Major » Normal

Interesting 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.

Maico de Jong’s picture

Status: Active » Needs review
FileSize
11.18 KB

Would 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.

  • gbyte.co committed b5fbd61 on 8.x-2.x
    git commit -m 'Issue #2903165 by MDJ Webdiensten, zenimagine: Add images...
gbyte’s picture

Status: Needs review » Fixed

Thanks @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!

zenimagine’s picture

thank you for your work, I will test it

gbyte’s picture

Status: Fixed » Needs review

@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?

zenimagine’s picture

the 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()

gbyte’s picture

@zenimagine You probably haven't run /update.php after the update.

zenimagine’s picture

Thank 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.

zenimagine’s picture

An option for the administrator to select the image style to index would be great.

gbyte’s picture

@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

An option for the administrator to select the image style to index would be great.

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?

Maico de Jong’s picture

@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.

gbyte’s picture

Status: Needs review » Fixed

@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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

FiNeX’s picture

Hi, 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?

gbyte’s picture

I 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.

gbyte’s picture