Support » Plugin: Hammy » Add Microdata to Original Image

  • Hi There, I am hoping that you can help me to add Schema.org data to the output of the hammy plugin.

    <a href="http://domain.com/wp-content/uploads/2014/02/image.jpg">
    <picture class="hammy-responsive alignnone size-large wp-image-90074" alt="image" title="">
      <source src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615/-298593907.jpg">
      <source src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615/1507488356.jpg" media="(min-width:120px)">
      <source src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615/887452201.jpg" media="(min-width:150px)">
      <source src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615/-295604654.jpg" media="(min-width:320px)">
      <source src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615/-333297845.jpg" media="(min-width:480px)">
      <noscript>
      <img src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615.jpg" alt="image" title="">
      </noscript>
    </picture>
    </a>

    So what I basically need to do is add the itemprop="image"
    to the output <a href="http://domain.com/wp-content/uploads/2014/02/image.jpg" itemprop="image">

    Your help will be much appreciated

    https://wordpress.org/plugins/hammy/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Noel Tock

    (@noel_tock)

    Hi Gerald,

    I think this makes sense, I’ll chuck in an option for that I think, this way people who aren’t using schema don’t need unnecessary DOM in their code.

    Cheers!

    Excellent – Thanks Noel much appreciated – I have in the meantime added this to my function file…

    function my_remove_rel_attr($content) {
        return preg_replace('/\s+rel="attachment wp-att-[0-9]+"/i', ' itemprop="image" ', $content);
    }
    add_filter('the_content', 'my_remove_rel_attr');

    which basically adds the itemprop="image" code on the link to the image…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add Microdata to Original Image’ is closed to new replies.