I want to set the default link css class to all those images which are added to admin editor. I have found the way to add default image class with this action:

function add_image_class($class){
    $class .= ' img-frame';
    return $class;

but couldn't find the way to do the same with "Link CSS Class"

Link CSS Class

  • get_link_tag_class isn't a core WordPress filter. Where did you get it? Nov 30, 2017 at 14:17
  • sorry, I have edited the question, it should be get_image_tag_class. I was able to set the image class with this filter and now i'm looking for similar solution with "link CSS Class" option Nov 30, 2017 at 14:27

1 Answer 1


I believe you can use wp_get_attachment_image_attributes filter here like so:

function custom_class( $attr ) {    
    $attr['class'] = 'custom-class';
    return $attr;
add_filter( 'wp_get_attachment_image_attributes', 'custom_class' );
  • thank you but this doesn't work. Maybe this will work on featured images, but not the images which are uploaded in editor Dec 1, 2017 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.