-
AuthorPosts
-
January 10, 2015 at 7:36 am #377734
Hello and Happy New Year to all the Kriesi team!
I just started using the Masonry Galley element on my homepage to add some images that include only the title and link to other site pages. After I tested my homepage with the Google Structured Data Testing Tool I realized that the Masonry Gallery cases several Errors.
First: On the hatom-entry is missing “updated” required field & “author” required hCard.
Second: It adds property “contenturl” which is not part of the schema (schema.org/webpage).The only reason that I can think of that is causing those errors, is because Masonry Gallery doesn’t differentiate a Page link from a Blog link, when a Page link is selected from the dropdown menu and it treats ALL links on the images as being linked to a blog post, which includes the “author”, “updated” and “contenturl” markups, while a Page article does not.
The reason that I believe that this is a bug is that if you also look at the demo’s Masonry Gallery page that all images open in a lightbox, you can see that it also creates the same errors here: http://www.google.com/webmasters/tools/richsnippets?q=http%3A%2F%2Fkriesi.at%2Fthemes%2Fenfold%2Fshortcodes%2Fmasonry-gallery%2F
Now, if you test the demo’s Masonry Bog page that the images are linked to blog posts you can see that there are no errors here: http://www.google.com/webmasters/tools/richsnippets?q=http%3A%2F%2Fkriesi.at%2Fthemes%2Fenfold%2Fblog%2Fmasonry-blog%2FThere should be a condition within the Masonry Gallery element to differentiate blog post links from page and other image links so it does not add mark up that only belongs to a blog post.
How can I fix this bug?
Thank you!
GeorgeJanuary 12, 2015 at 6:55 pm #378452Hey sdbroker!
I’m not really sure how the rich snippets work but I think google is getting confused because we are adding the class “hentry” to each of the masonry gallery images so it thinks these are actual posts when they are just images you have selected to display.
The reason that gets added is because for the Masonry Gallery we are just simply using the Masonry Entries class so it uses the same code. I was having a hard time tracking it down though so I’ll flag this for the rest of our team to take a look.
Regards,
ElliottJanuary 12, 2015 at 9:42 pm #378536Hi Elliott,
Thank you for looking into this! I added the code below at the end of the functions.php that removes the “hentry” class if it’s a page and it fixed the first error “missing updated & author”.
function ga_remove_hentry( $classes ) { if ( is_page() ) { $classes = array_diff( $classes, array( 'hentry' ) ); } return $classes; } add_filter( 'post_class','ga_remove_hentry' );
I still need a fix for the second issue reporting that “contenturl” is not part of the “schema.org/webpage” markup. I think that the proper way to fix this is by having a conditional code in functions.php file to replace the “contenturl” markup that comes from “schema.or/imageobject” with “significantLink” or even just a “URL” markup ONLY for images that link to a page, but I don’t know how to code this.
Thank you,
GeorgeJanuary 13, 2015 at 7:19 pm #379035Hey!
Try changing that on line 108 in /enfold/includes/helper-markup.php.
$attributes['itemprop'] = 'contentURL';
Cheers!
ElliottJanuary 13, 2015 at 11:41 pm #379187Hi Elliott,
Changing line 108 in the helper-markup.php file is the easy shortcut that fixes this particular error on the Masonry Gallery element when page links are used instead of the lightbox. BUT it creates errors on all other elements (sliders, image gallery, etc) that use the “imageobject” markup when the attached images DON’T include a link to a page.
The problem with the Masonry Gallery is that it does not take into consideration images having links to a page that display the page url link instead of the image url and by default attaches the property “contentUrl” to the page url which should be attached only to an image url. The code needs to be changed so “contenturl” property is correctly attached to an image url BUT “significantLink” or “url” should be attached to images that include page links. By default, Images not attached to a page display the image url in which case the “contenturl” property is correctlu applied, while images that are attached to a page display the title or alt url in which case the “contenturl” property produces errors.
That is why I suggested earlier that a conditional code is needed to be added so it will apply the correct property on images without a link to a page and to images with a link to a page.
Thank you,
GeorgeJanuary 15, 2015 at 5:23 pm #380139Hey!
In /enfold/config-templatebuilder/avia-shortcodes/masonry_entries.php on line 576 you can see we set the context to “image_url”.
$markup = ($post_type == 'attachment') ? avia_markup_helper(array('context' => 'image_url','echo'=>false, 'id'=>$entry['ID'], 'custom_markup'=>$this->atts['custom_markup'])) : avia_markup_helper(array('context' => 'entry','echo'=>false, 'id'=>$entry['ID'], 'custom_markup'=>$this->atts['custom_markup']));
That’s the conditional your looking for. You could change that to “significantURL” and then add a new case in this file, https://kriesi.at/support/topic/masonry-gallery-structured-data-bug/#post-379035.
Cheers!
ElliottJanuary 15, 2015 at 9:27 pm #380453Hi Elliott!
Brilliant! As you suggested I replaced ‘image_url’ with ‘image_link’ on line 576 in the masonry_entries.php file and then created a new case for ‘image_link’ on the helper-markup.php file that returns ‘itemprop’ = ‘significantLink’ and now both properties for images without a link to a page and for images with a link to a page return the correct markup without producing errors.
Shouldn’t this fix be added as a permanent fix to the upcoming theme’s update since it also solves the errors on the demo pages?
Thank you very much for your help… You are brilliant!
Best regards,
George -
AuthorPosts
- The topic ‘Masonry Gallery – Structured Data Bug’ is closed to new replies.