• Hello,

    I want to add an image class to all images uploaded in posts.
    At the moment my img code looks like this

    <img class="alignleft size-thumbnail wp-image-46" width="400" height="598" alt="" src="https://mysite.com/minibook/wp-content/uploads/2011/07/tumblr_loaiyhK8vu1qdu3vi-400x598.png" title="Homme Japan">

    is there a way to set the image class to a default so all my post images have the same class?

Viewing 1 replies (of 1 total)
  • im not sure if this is what youre looking for, but it worked for me…

    I needed to wrap all of my images with a class to trigger a javascript workaround. since div didnt work in this example, i used span and it worked.

    added this to functions.php

    // WRAP UPLOADED IMAGES IN CLASS
    if(is_admin()){
    
      add_filter('image_send_to_editor', 'wrap_my_div', 10, 8);
    
      function wrap_my_div($html, $id, $caption, $title, $align, $url, $size, $alt){
        return '<span class="rame-img" id="mydiv-'.$id.'">'.$html.'</span>';
      }
    }

    code came from here

Viewing 1 replies (of 1 total)
  • The topic ‘Add/set class to all post images’ is closed to new replies.