WordPress.org

Ready to get started?Download WordPress

Forums

Hammy
Add Microdata to Original Image (3 posts)

  1. GeraldFerreira
    Member
    Posted 5 months 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)">
      <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/

  2. Noel Tock
    Human Made
    Plugin Author

    Posted 5 months 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.

    Cheers!

  3. GeraldFerreira
    Member
    Posted 5 months 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...

Reply

You must log in to post.

About this Plugin

About this Topic