Add Microdata to Original Image (3 posts)

  1. GeraldFerreira
    Posted 2 years ago #

    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)">
      <img src="http://domain.com/wp-content/uploads/cache/2014/02/image/278439615.jpg" alt="image" title="">

    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


  2. Noel Tock
    Human Made
    Plugin Author

    Posted 2 years ago #

    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.


  3. GeraldFerreira
    Posted 2 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Hammy
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic