• Hello guys

    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

    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');
    
    }

The topic ‘how to add_filter to function ?’ is closed to new replies.