Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

the idea is apply some filters if the user select the option in the theme, but i have a problem

i made a function that replace the post_thumbnail_html for a personalized html

then, i create other function that create thumnails for timthumb

i'm trying to apply the add_filter to the timthumb function, but it doesn't work because is not a wordpress hook

can you helpme?

function kandombe_theme_thumb($id, $width, $height, $align='') {

        //some code

        $html = '<img class="archive_thumb" src='.$image_url.' width="'.$width.'" height="'.$height.'"/>';

        return $html;

    }

if ($data['speed_lazy_loading']) { 

    function kandombe_lazy_loads( $html ) {

        //some code

        $html = preg_replace( '#<img([^>]+?)src=[\'"]?([^\'"\s>]+)[\'"]?([^>]*)>#', sprintf( '<img${1}src="%s" data-original="${2}"${3} style="display: block;"><noscript><img${1}src="${2}"${3}></noscript>', $placeholder_image ), $html );

    return $html;
    }

add_filter( 'the_content', 'kandombe_lazy_loads');
add_filter( 'post_thumbnail_html', 'kandombe_lazy_loads');
add_filter( 'kandombe_theme_thumb', 'kandombe_lazy_loads');
add_filter( 'get_avatar', 'kandombe_lazy_loads');

}
share|improve this question
add comment

1 Answer

Assuming that this-- add_filter( 'kandombe_theme_thumb', 'kandombe_lazy_loads');-- is the line/hook you are talking about.

You don't hook to functions. That is not how it works. Hooks have to be intentionally created with apply_filters or do_action. Your code would have to be written like this for that to work:

function kandombe_theme_thumb($id, $width, $height, $align='') {
    //some code
    $html = apply_filters(
      'kandombe_theme_thumb',
      '<img class="archive_thumb" src='.$image_url.' width="'.$width.'" height="'.$height.'"/>'
    );
    return $html;
}

Related

http://wordpress.stackexchange.com/a/103644/21376

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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