252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

Hi guys!

Timthumb is no longer allowed as part of Envato’s quality guidelines. Fellow authors have developed excellent alternatives for timthumb, such as Freshizer, BFI-Thumb and Aqua.

I’ve released an image resizing script which I use in my themes. Uses WordPress native image processing functions. It’s compatible with WordPress 3.5+ and below.

The script supports Positional Cropping. Thumbnails are automatically deleted when the original image is removed from the Media Library, and degrades gracefully in case of errors.

Feel free to use it on your projects. Use and abuse under the GPLv2 License.

Get the code here: https://github.com/derdesign/mr-image-resize

Enjoy!

1052 posts
  • Forum Superstar
  • Most Wanted Bounty Winner
  • Envato Studio (Microlancer) Beta Tester
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Referred between 50 and 99 users
  • Europe
  • Has been a member for 3-4 years
  • Exclusive Author
+1 more
Smartik says

Another good script. Thank you for sharing. Will give it a test when I will have free time. ;)

292 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

Great work :)

I have following questions

- Does it first check if the image size exist already? - Does it require specific directory permissions otherwise it will give error? - What’s the advantage of using this over the WordPress native resize function?

252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

Great work :)

I have following questions

- Does it first check if the image size exist already? - Does it require specific directory permissions otherwise it will give error? - What’s the advantage of using this over the WordPress native resize function?

- Yes, it checks if the image exists already
- No, it uses the same WordPress Uploads directory
- The whole process is abstracted for you. Works on Multisite. Positional Cropping.

292 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

Thanks for answering. I couldn’t find any example on how to use it (eg. how to call the function to display an image in the loop). Could you please give an example?

252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

Thanks for answering. I couldn’t find any example on how to use it (eg. how to call the function to display an image in the loop). Could you please give an example?
// Put this in your functions.php
function theme_thumb($url, $width, $height=0, $align='') {
  return mr_image_resize($url, $width, $height, true, $align, false);
}

$thumb = theme_thumb($image_url, 800, 600, 'br'); // Crops from bottom right

echo $thumb;

I’ve added the usage example on the github repo, for further reference…

292 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

I have added that in my functions.php and I’m using following code in my post and its not working, I have made sure that the image url is correct.

$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full");
$image_url = $image_src[0];
$thumb = theme_thumb($image_url, 800, 600, 'br');
echo $thumb;

I’m getting following warning:

Warning: Missing argument 1 for mr_common_info(), called in mr-image-resize.php on line 135
252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

@crossroad I’ve spotted this error and fixed it a while ago. Re-download the code from the latest commit.

It’ll work ;)

292 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

Yes, it works now, thanks. Have you checked it there are any other bugs? :)

252 posts
  • Elite Author
  • Won a Competition
  • Has been a member for 5-6 years
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
der says

Yes, it works now, thanks. Have you checked it there are any other bugs? :)

I’ve tested it thoroughly and as far as I can tell, no other bugs that I know of.

by
by
by
by
by
by