Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter sklundy

    (@sklundy)

    Resolved. To make timthumb apply to the entirety of a post, use the following code:

    <?php ob_start();
       the_content('Read the full post',true);
    
    $postOutput= preg_replace('#<img(.*?)src="([^"]*/)?(([^"/]*)\.[^"]*)"([^>]*?)>#', '<a href=$2$3><img$1src="https://....timthumb.php?src=$2$3&w=476&h=275&zc=1&q=200"></a>', ob_get_contents());  
    
       ob_end_clean();
       echo $postOutput;
     ?>

    Simply add a number as the fourth parameter in preg_replace().

    For example, I’ve limited the following code (from the link you provided) to removing replacing ONCE:

    $first_img = str_replace('https://yourwebsite.com', '', $first_img,1 );

    You are dealing with the “limit” parameter.

    See more here:

Viewing 2 replies - 1 through 2 (of 2 total)