meghlal / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

External images #127

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Does anyone have a simple solution to resize images on the same server but on a 
subdomain?

blog1.domain.com
blog2.domain.com 
etc. etc.

I have a function that picks up the first image URL in every wordpress post and 
puts it in front of timthumb url.

This is my function:

// Get URL of first image in a post
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', 
$post->post_content, $matches);
$first_img = $matches [1] [0];

// no image found display default image instead
if(empty($first_img)){
$first_img = "/images/default.jpg";
}
return $first_img;
}

how i display my thumb (or try):
<img src="script/timthumb.php?src=<?php echo catch_that_image() 
?>&h=180&w=222&zc=1" alt="<?php the_title(); ?>"/>

Big thanks,

Dennis

Original issue reported on code.google.com by dennis.t...@gmail.com on 1 Nov 2010 at 9:09

GoogleCodeExporter commented 9 years ago
Hi Dennis - this isn't a bug but a support request and I'm afraid this is the 
wrong place to put those. This sounds like a WordPress mu problem so I would 
suggest reading this: http://www.binarymoon.co.uk/2009/10/timthumb-wordpress-mu/

Alternatively you could adjust timthumb so that it works on external domains: 
http://www.binarymoon.co.uk/2010/08/timthumb-part-2-external-websites/

Original comment by BinaryMoon on 4 Nov 2010 at 8:52