Support » Fixing WordPress » filtering "wp_get_attachment_image_attributes" fails

  • Resolved helgatheviking


    on line 659 of includes/media.php i found an interesting filter

    $attr = apply_filters( ‘wp_get_attachment_image_attributes’, $attr, $attachment );

    i thought i’d use it to try out some things I am working regarding serving responsive images. i thought i knew how to filter, but even just trying to pass the array of attributes (unchanged) back to the filter produces

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ' kia_attachment_attributes' not found or invalid function name in *****\wp-includes\plugin.php on line 166

    normally i get this error when i mismatch the name of the function with the name of the function being added to the filter, but i’ve copied and pasted them and they’re the same. here is my code:

    function kia_attachment_attributes($attr) {
    	return $attr;
    add_filter('wp_get_attachment_image_attributes', ' kia_attachment_attributes', 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘filtering "wp_get_attachment_image_attributes" fails’ is closed to new replies.