Advertisement
bigbadboy

Clear image attributes (good when going responsive)

Jul 4th, 2012
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. // CLEAR IMAGES ATTRIBUTES
  2. function image_tag_class($class, $id, $align, $size) {
  3.     $align = 'align' . esc_attr($align);
  4.     return $align;
  5. }
  6. add_filter('get_image_tag_class', 'image_tag_class', 0, 4);
  7. function image_tag($html, $id, $alt, $title) {
  8.     return preg_replace(array(
  9.             '/\s+width="\d+"/i',
  10.             '/\s+height="\d+"/i',
  11.             '/alt=""/i'
  12.         ),
  13.         array(
  14.             '',
  15.             '',
  16.             '',
  17.             'alt="' . $title . '"'
  18.         ),
  19.         $html);
  20. }
  21. add_filter('get_image_tag', 'image_tag', 0, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement