WordPress Plugin: AutoThumb

After switching my blog to WordPress I needed a simple solution which allowed me to flexibly post images in different sizes without having to hassle with different filenames, paths etc.

The plugin is actually just a port of a plugin/snippet I wrote for MODx a while ago (see here). It scans your content’s source code for <img> tags with width and height attributes and passes them to phpThumb, a great PHP image editing library, which handles the resizing and editing of the image. Additionally, by passing parameters to phpThumb using a query string, it’s possible to edit the image in several ways (take a look at phpThumb’s demos).

The simplest way to get resized images is to specify width/height attibutes in your HTML. Autothumb will use the given values and remove the attributes from your page’s output. When you take a look at the URLs of the following example images, you will see that the <img>-tag’s src-attribute points to a file called image.php in the plugin’s directory. This file takes the image source and several other parameters and passes them to phpThumb, which will generate and output the final image (of course images will be cached).

To prevent evil people playing with the query string and letting your server generate tons of different images, the plugin generates a hash which is a combination of the query string and a secret password you set in phpThumb’s config file. So every call with different parameters (even the same image with different sizes) has another unique hash and it’s not possible to generate new images without knowing the secret password.

Basic usage

Just use images in your content and set width and height HTML attributes. The plugin will scan your content and pass the right parameters to phpThumb, which will generate the appropriate image sizes. The plugin works on 3 types of URLs:

  • relative URLs (do not begin with a slash, example: wp-content/uploads/myimage.jpg) start at your WordPress installation root, even if you installed WordPress in a subdirectory of your server. Use this type of URLs if you want a simple setup without much hassle, even when you move your WP installation.
  • absolute URLs (begin with a slash, example /subdirectory/wp-content/myimage.jpg) start at your server’s document root. If you use this type of URLs, remember to include your WP installation subdirectory
  • full URLs (example http://example.com/subdirectory/wp-content/uploads/myimage.jpg) point to an absolute location. I suggest using full URLs only when you point to external images

If you insert images from the WP media library, it’s the best to delete the URL part before wp-content in order to get relative URLs.

Examples

As an example, I will take this photo I found on Flickr:

<img src="path/to/image.jpg" alt="" width="600" />

Of course, this also works with the height attribute or with both attributes combined.

<img src="path/to/image.jpg" alt="" height="200" />

<img src="path/to/image.jpg" alt="" width="150" height="200" />

Advanced examples

You can use all phpThumb functions and filters (see phpThumb demo page and readme) depending on your server’s configuration (GD version, ImageMagick, …) by passing them as query string:

http://example.com/path/to/image.jpg?param1=value1&param2=value2&...

The only difference to the demo page: when using filters, make sure that you use curly brackets {} instead of square ones []. Multiple filters like ?fltr{}=sep&fltr{}=blur|5 do not work with this release, but I will see to update it as soon as possible.. With version 0.2 multiple filters are working as shown on phpThumb’s demo page. No need to use curly brackets (altough they still work) anymore.

Crop / Zoom Crop

<img src="path/to/image.jpg?zc=1" alt="" width="400" height="150" />

<img src="path/to/image.jpg?zc=1" alt="" width="120" height="120" />

Blur filter

<img src="path/to/image.jpg?fltr[]=blur|2" alt="" width="400" />

Sepia

<img src="path/to/image.jpg?fltr[]=sep" alt="" width="400" />

Combined Filters (new in 0.2)

<img src="path/to/image.jpg?fltr[]=lvl|*|2&fltr[]=hist|rgb||||BR|100&fltr[]=hist|*||||BL|100" alt="" width="400" />

Rounded corners

<img src="path/to/image.jpg?w=400&fltr[]=ric|30|30&fltr[]=sat|-100&fltr[]=cont|30&f=png" alt="" />

For more examples just visit the phpThumb page linked above.

Advanced topics

Usage on custom content

By default AutoThumb automatically operates on the_content() (you can switch this behaviour off via the admin panel). However, you can run the function on any other content you’d like to. All img tags found in that content will be replaced with calls to phpThumb as described above. The autothumb function has the following signature:

<?php
/**
 * autothumb
 *
 * Automatically rewrite img tags to phpThumb
 *
 * @param  string $content  the content containing img tags
 * @return string
 */
function autothumb($content) {}
?>

You can use the function as WordPress filter (as it is used by the plugin):

<?php
add_filter('the_content', 'autothumb');
?>

Otherwise you can just run the function on your content:

<?php
$mycontent = autothumb($mycontent);
?>

Usage on single images

You can use the function used to generate phpThumb URLs manually on single images (e.g. in your templates). The function has the following signature:

<?php
/**
 * getphpthumburl
 *
 * Creates an URL to phpThumb
 *
 * @param string $image         the path/URL to the image
 * @param string $params        phpThumb parameters
 * @param bool   $xhtmlOutput   if set to false, URLs won't contain escaped HTML entities (e.g. &)
 * @return string
 */
function getphpthumburl($image, $params = 'w=800', $xhtmlOutput = true) {}
?>

An example:

<img src="<?php echo getphpthumburl('wp-content/uploads/image.jpg', 'h=90&w=90&zc=1'); ?>" alt="my resized image" />

Clean URLs

Since version 0.4, AutoThumb is able to use rewritten URLs (using mod_rewrite) to generate cleaner URLs to your resized images. Some JS-Lightboxes have problems with the standard URLs (wp-content/plugins/autothumb/image.php?src=image.jpg&w=600) and don’t recognize the output as image. Using the clean URL feature you can guide AutoThumb to generate nicer and more compatible URLs. Example:

/images/path/to/myimage.jpg?w=100&h=100&zc=1

As the path part of these URLs ends with the image filename, chances that the generated images are displayed correctly by Lightbox scripts are much better. You can activate this feature in the option panel. In addition, you can change the base path used for AutoThumb images (it’s images in the above example). AutoThumb tries to automatically edit your .htaccess file and will show you the needed rewrite rules if it is not able to alter the file.

Switch off processing on single images

You got two possibilities to switch off processing of specific images (e.g. you have AutoThumb activated on the_content but want some images to stay untouched. You can use a HTML attribute called process (will be removed on output):

<img src="path/to/image.jpg" alt="" process="0" />

Or you can do the same thing by specifying an URL parameter:

<img src="path/to/image.jpg?process=0" alt="" />

Installation

  • Download the .zip file and extract it.
  • Upload the plugin to your /wp-content/plugins/ directory and make sure your web server has write access to the cache folder and the config file.
  • Activate the plugin.
  • Go to Settings - Autothumb and setup the plugin. (Especially the password as this is important to prevent abuse of the script).
  • Have fun!

Upgrading

Just delete the old plugin directory, upload the new one and reactivate the plugin (or upgrade the plugin via the WordPress plugin installer).

Changelog

0.5

  • add possibility to switch off image processing on single images through the process HTML attribute or URL parameter

0.4

  • fixed path and URL handling issues
  • added “clean URLs” feature
  • improved the options page

0.3

  • added option panel for PHPThumb’s high security password (thanks to Ben)

0.2

  • added possibilty to use multiple filters
  • updated to phpThumb version 1.7.9 (beta)
  • some minor bugfixes

0.1

  • first release

Download

You can grab the latest version of the plugin from the wordpress repository.

  • DisBas

    Thanks for the plugin. It’s absolutely a gem! I having a slight problem with it, though. Hope you can shed some light..

    I’m desiging a theme in which I use the Custom Fields to display a photo I uploaded. The php below is in home.php (key=photo, value=url of photo):


    if (get_post_meta($post->ID, 'photo', true) != null) {
    echo '<a href="';
    the_permalink();
    echo '" title="';
    the_title_attribute();
    echo '">ID, $key, true);
    echo '?zc=1" alt="" width="350" height="225" /></a>';
    } else {}

    The plugin seems to ignore this particular image. It’s not being cropped, just scaled. Regular images in the posts are being cropped, though.

    Any suggestions on how to fix this, are appreciated.

  • DisBas

    Thanks for the plugin. It’s absolutely a gem! I having a slight problem with it, though. Hope you can shed some light..

    I’m desiging a theme in which I use the Custom Fields to display a photo I uploaded. The php below is in home.php (key=photo, value=url of photo):


    if (get_post_meta($post->ID, 'photo', true) != null) {
    echo '<a href="';
    the_permalink();
    echo '" title="';
    the_title_attribute();
    echo '">ID, $key, true);
    echo '?zc=1" alt="" width="350" height="225" /></a>';
    } else {}

    The plugin seems to ignore this particular image. It’s not being cropped, just scaled. Regular images in the posts are being cropped, though.

    Any suggestions on how to fix this, are appreciated.

  • http://maff.ailoo.net/ Mathias

    Hey, I’m glad the plugin is useful to you. Unfortunately, your code got a bit obfuscated by WordPress’ comment engine. Could you try to re-post your code and wrap it in the source tag mentioned in the comment instructions below or send me a copy of your snippet via email?

  • http://maff.ailoo.net/ Mathias

    Hey, I’m glad the plugin is useful to you. Unfortunately, your code got a bit obfuscated by WordPress’ comment engine. Could you try to re-post your code and wrap it in the source tag mentioned in the comment instructions below or send me a copy of your snippet via email?

  • http://maff.ailoo.net/ Mathias

    Hi again,

    you were right with your assumption that your snippet does not work because the plugin affects only the_content. You can, however, use the getphpthumburl function which takes care of constructing the URLs.

    “`php

    “`

    hth,
    maff

  • http://maff.ailoo.net/ Mathias

    Hi again,

    you were right with your assumption that your snippet does not work because the plugin affects only the_content. You can, however, use the getphpthumburl function which takes care of constructing the URLs.

    “`php
    < ?php echo getphpthumburl('http://path/to/image.jpg', 'w=350&h=225&zc=1'); ?>
    “`

    hth,
    maff

  • DisBas

    Thanks! Works absolutely perfect.. I’ve been looking for ages for a plugin that can do this. Can I buy you a coffee for this?

    The endresult:

    “`php
    ID, ‘foto’, true) != null) {
    print ‘ID, $key, true);
    echo getphpthumburl($photo, ‘w=350&h=225&zc=1′);
    print ‘” />
    ‘;
    } else {}
    ?>
    “`

  • DisBas

    Thanks! Works absolutely perfect.. I’ve been looking for ages for a plugin that can do this. Can I buy you a coffee for this?

    The endresult:

    “`php
    < ?php
    if (get_post_meta($post->ID, ‘foto’, true) != null) {
    print ‘ $photo = get_post_meta($post-/>ID, $key, true);
    echo getphpthumburl($photo, ‘w=350&h=225&zc=1′);
    print ‘” />
    ‘;
    } else {}
    ?>
    “`

  • http://maff.ailoo.net/ Mathias

    Nice to hear :)

    As the plugin is just a wrapper and the real work is done by phpThumb, you could rather consider to buy James Heinrich a coffee ;)

    Cheers,
    maff

  • http://maff.ailoo.net/ Mathias

    Nice to hear :)

    As the plugin is just a wrapper and the real work is done by phpThumb, you could rather consider to buy James Heinrich a coffee ;)

    Cheers,
    maff

  • http://dancameron.org Dan Cameron

    Maff,

    I wanted to mention your download link is broken.

    Thanks for the awesome plugin, haven’t used it yet but it look promising. I’ll be downloading it through SVN shortly.

  • http://dancameron.org Dan Cameron

    Maff,

    I wanted to mention your download link is broken.

    Thanks for the awesome plugin, haven’t used it yet but it look promising. I’ll be downloading it through SVN shortly.

  • http://maff.ailoo.net/ Mathias

    Dan,

    thanks for your advice :) I fixed the problem and the download should work again now.

  • http://maff.ailoo.net/ Mathias

    Dan,

    thanks for your advice :) I fixed the problem and the download should work again now.

  • Pingback: Scattered » Blog Archive » Twitter Updates for 2008-12-02()

  • http://wwww.turkbaron.net baron

    Works great, thank you.

  • http://wwww.turkbaron.net baron

    Works great, thank you.

  • Pingback: AutoThumb – WP Plugin Archive()

  • Pingback: links for 2009-04-21 | Blog Wolkanca()

  • Ben

    This is exactly what’s missing from wordpress, this and a file upload custom field type so you can upload images outside of the post and style them in themes directly – cut and pasting to the extra fields is soooo old.

    Have you tried to add a control panel to set the $PHPTHUMB_CONFIG[‘high_security_password’] variable from within wordpress?

    I’ve added the gui, but then had a brain fade over how to resolve the scope issues between wordpress and phpThumb without fully integrating wordpress into it…

    eg GUI addition to top autothumb.php becomes:
    “`php
    /*
    * Ben – Add in options panel
    */
    add_option(‘wh_password’, ‘Type your own password here’, “”, true);
    /**
    * Add options page to admin menu
    */
    function wh_add_options() {
    add_options_page(‘Authothumb options’, ‘Autothumb’, 8, basename(__FILE__), ‘wh_options_subpanel’);
    }
    function wh_options_subpanel(){
    include( “options-panel.php” );
    }
    add_action(‘admin_menu’, ‘wh_add_options’);
    /*
    * End Ben mods
    */
    “`
    And a matching panel (options-panel.php) using wp2.7.1 css would be
    “`php

    Autothumb Options

    Secret Key:

    “`
    But of course I can’t just do
    $PHPTHUMB_CONFIG[‘high_security_password’] = get_option(“wh_password”);
    because the config is out of scope of the wordpress instance…
    Any thoughts?

    • http://maff.ailoo.net/ Mathias

      @Ben thank you for your feedback and your addition :) I think the most practicable way is just writing the password back to phpthumb.config.php after setting it in the admin interface. I’ll take a look at this shortly.

  • Ben

    This is exactly what’s missing from wordpress, this and a file upload custom field type so you can upload images outside of the post and style them in themes directly – cut and pasting to the extra fields is soooo old.

    Have you tried to add a control panel to set the $PHPTHUMB_CONFIG[‘high_security_password’] variable from within wordpress?

    I’ve added the gui, but then had a brain fade over how to resolve the scope issues between wordpress and phpThumb without fully integrating wordpress into it…

    eg GUI addition to top autothumb.php becomes:
    “`php
    /*
    * Ben – Add in options panel
    */
    add_option(‘wh_password’, ‘Type your own password here’, “”, true);
    /**
    * Add options page to admin menu
    */
    function wh_add_options() {
    add_options_page(‘Authothumb options’, ‘Autothumb’, 8, basename(__FILE__), ‘wh_options_subpanel’);
    }
    function wh_options_subpanel(){
    include( “options-panel.php” );
    }
    add_action(‘admin_menu’, ‘wh_add_options’);
    /*
    * End Ben mods
    */
    “`
    And a matching panel (options-panel.php) using wp2.7.1 css would be
    “`php

    Autothumb Options

    < ?php wp_nonce_field('update-options'); ?>

    ” />


  • http://maff.ailoo.net/ Mathias

    @Ben thank you for your feedback and your addition :) I think the most practicable way is just writing the password back to phpthumb.config.php after setting it in the admin interface. I’ll take a look at this shortly.

  • Pingback: Empfehlungen vom Donnerstag, 23. April 2009 | Biggle's Blog()

  • Ben

    Hmmm…well sometimes the simplest ways are the best..

    If we go that way then here’s a quick hack that works on PHP5 (file_put_contents() is 5 only I think), my mod to autothumb becomes:

    “`php
    Author URI: http://ailoo.net/
    */

    define(AUTOTHUMB_PATH, dirname(__FILE__).’/’);

    /*
    * Ben – Add in options panel
    */
    add_option(‘wh_password’, ‘Type your own password here’, “”, true);
    /**
    * Add options page to admin menu
    */
    function wh_add_options() {
    add_options_page(‘Authothumb options’, ‘Autothumb’, 8, basename(__FILE__), ‘wh_options_subpanel’);
    }
    function wh_options_subpanel(){
    include( “options-panel.php” );
    }
    function wh_update_password(){
    $configFile = AUTOTHUMB_PATH.”phpthumb/phpThumb.config.php”;
    // retrieve the file into an array where each line is a value
    $Array = file($configFile);
    // now find the line in the config file that starts with the assignment of
    $needle = “/^s*\$PHPTHUMB_CONFIG[‘high_security_password.*/”;
    $i=0;
    foreach($Array as $v){
    $v = rtrim($v, “rn”) . PHP_EOL;
    if(preg_match($needle,$v)) $results[] =$i;
    $i++;
    }
    $Array[$results[0]]=”$PHPTHUMB_CONFIG[‘high_security_password’] = ‘”.get_option(‘wh_password’).”‘; // This line altered by WordPress. “.PHP_EOL;
    // implode the array into string, line breaks separation is already there from the original file function so put everything back in the file
    file_put_contents($configFile, implode($Array));
    }
    add_action(‘admin_menu’, ‘wh_add_options’);
    add_action(‘update_option_wh_password’, ‘wh_update_password’);
    /*
    * End Ben mods
    */
    function autothumb($content)
    {
    $imagesearch = array();
    “`

    Its late and I’m going to bed, hope this helps! I’m sure it needs some polishing/rewriting but the concept works on my test box.
    Cheers,
    Ben

  • Ben

    Hmmm…well sometimes the simplest ways are the best..

    If we go that way then here’s a quick hack that works on PHP5 (file_put_contents() is 5 only I think), my mod to autothumb becomes:

    “`php
    Author URI: http://ailoo.net/
    */

    define(AUTOTHUMB_PATH, dirname(__FILE__).’/’);

    /*
    * Ben – Add in options panel
    */
    add_option(‘wh_password’, ‘Type your own password here’, “”, true);
    /**
    * Add options page to admin menu
    */
    function wh_add_options() {
    add_options_page(‘Authothumb options’, ‘Autothumb’, 8, basename(__FILE__), ‘wh_options_subpanel’);
    }
    function wh_options_subpanel(){
    include( “options-panel.php” );
    }
    function wh_update_password(){
    $configFile = AUTOTHUMB_PATH.”phpthumb/phpThumb.config.php”;
    // retrieve the file into an array where each line is a value
    $Array = file($configFile);
    // now find the line in the config file that starts with the assignment of
    $needle = “/^\s*\\\$PHPTHUMB\_CONFIG\[\’high_security_password.*/”;
    $i=0;
    foreach($Array as $v){
    $v = rtrim($v, “\r\n”) . PHP_EOL;
    if(preg_match($needle,$v)) $results[] =$i;
    $i++;
    }
    $Array[$results[0]]=”\$PHPTHUMB_CONFIG[‘high_security_password’] = ‘”.get_option(‘wh_password’).”‘; // This line altered by WordPress. “.PHP_EOL;
    // implode the array into string, line breaks separation is already there from the original file function so put everything back in the file
    file_put_contents($configFile, implode($Array));
    }
    add_action(‘admin_menu’, ‘wh_add_options’);
    add_action(‘update_option_wh_password’, ‘wh_update_password’);
    /*
    * End Ben mods
    */
    function autothumb($content)
    {
    $imagesearch = array();
    “`

    Its late and I’m going to bed, hope this helps! I’m sure it needs some polishing/rewriting but the concept works on my test box.
    Cheers,
    Ben

  • http://maff.ailoo.net/ Mathias

    @Ben I just released 0.3 including the admin panel. Thanks for the addition :)

  • http://maff.ailoo.net/ Mathias

    @Ben I just released 0.3 including the admin panel. Thanks for the addition :)

  • Ben

    Cool!

    As I said it was late, but when I woke up in the morning I realised that the PHP man page would probably help me to avoid thinking and so to make the file writing bit php4 compatible (not sure if the rest of it is though) just add in (apologies if you’ve already done this, I’ve not downloaded 0.3 yet to check):

    “`php
    if (!function_exists(‘file_put_contents’)) {
    function file_put_contents($filename, $data) {
    $f = @fopen($filename, ‘w’);
    if (!$f) {
    return false;
    } else {
    $bytes = fwrite($f, $data);
    fclose($f);
    return $bytes;
    }
    }
    }
    “`

    Also have you thought about adding in default thumbnail options to the control panel as well?

    You could still over ride them with the query string parameters from the function if specified, but otherwise allow the user to set the defaults in the control panel – and it would make the control panel look more useful ;-)

    I’m using your plugin along with the “Get the image” plugin plus a simple wrapper function to take the first image||custom field image||first attached image, set up a default set of parameters then create the required thumbnail – like this:

    “`php
    function wh_get_the_image($arg,$options=”) {
    /*
    * This relies on two plugins, and slightly modified versions of them at that
    * Get The Image – scans the post for the image and returns the first image found. Modifed to return a url
    * Autothumb – resize’s and caches the returned images. Modified to set the secret key from the WordPress Admin
    */
    $defaults = array (
    ‘image_scan’ => true,
    ‘attachment’ => false,
    ‘echo’=>false,
    ‘url’=>true);

    $options = wp_parse_args($options,$defaults);
    $img = get_the_image( $options);
    if ( $img ==”“) {
    echo “”;
    } else {
    echo getphpthumburl($img,$arg);
    }
    }
    “`
    In this case I don’t pass any default parameters to autothumb (my theme didn’t need it) but I do to the other plugin.

    Cheers,
    Ben

    • http://maff.ailoo.net/ Mathias

      @Ben indeed the default parameter feature is a nice idea, I’ll definitely take a look at this. And thanks for the PHP4 compatibilty function (even tough i dropped PHP4 a looong time ago), I’ll add it :)

  • Ben

    Cool!

    As I said it was late, but when I woke up in the morning I realised that the PHP man page would probably help me to avoid thinking and so to make the file writing bit php4 compatible (not sure if the rest of it is though) just add in (apologies if you’ve already done this, I’ve not downloaded 0.3 yet to check):

    “`php
    if (!function_exists(‘file_put_contents’)) {
    function file_put_contents($filename, $data) {
    $f = @fopen($filename, ‘w’);
    if (!$f) {
    return false;
    } else {
    $bytes = fwrite($f, $data);
    fclose($f);
    return $bytes;
    }
    }
    }
    “`

    Also have you thought about adding in default thumbnail options to the control panel as well?

    You could still over ride them with the query string parameters from the function if specified, but otherwise allow the user to set the defaults in the control panel – and it would make the control panel look more useful ;-)

    I’m using your plugin along with the “Get the image” plugin plus a simple wrapper function to take the first image||custom field image||first attached image, set up a default set of parameters then create the required thumbnail – like this:

    “`php
    function wh_get_the_image($arg,$options=”) {
    /*
    * This relies on two plugins, and slightly modified versions of them at that
    * Get The Image – scans the post for the image and returns the first image found. Modifed to return a url
    * Autothumb – resize’s and caches the returned images. Modified to set the secret key from the WordPress Admin
    */
    $defaults = array (
    ‘image_scan’ => true,
    ‘attachment’ => false,
    ‘echo’=>false,
    ‘url’=>true);

    $options = wp_parse_args($options,$defaults);
    $img = get_the_image( $options);
    if ( $img ==”“) {
    echo “”;
    } else {
    echo getphpthumburl($img,$arg);
    }
    }
    “`
    In this case I don’t pass any default parameters to autothumb (my theme didn’t need it) but I do to the other plugin.

    Cheers,
    Ben

    • http://maff.ailoo.net/ Mathias

      @Ben indeed the default parameter feature is a nice idea, I’ll definitely take a look at this. And thanks for the PHP4 compatibilty function (even tough i dropped PHP4 a looong time ago), I’ll add it :)

  • Claudiu

    where can I add a css syle to have the thumbnails float left in my count ?

    • http://maff.ailoo.net/ Mathias

      @Claudiu: Umm, maybe in your CSS file? ;) The plugin does only change the src, width and height attributes of images you specify in your markup. You can still define css classes, ids and so on. So styling is beyond the scope of this plugin.

  • Claudiu

    where can I add a css syle to have the thumbnails float left in my count ?

    • http://maff.ailoo.net/ Mathias

      @Claudiu: Umm, maybe in your CSS file? ;) The plugin does only change the src, width and height attributes of images you specify in your markup. You can still define css classes, ids and so on. So styling is beyond the scope of this plugin.

  • http://www.superprofenchine.com/wp/ Arnauld

    very nice plugin, thanks, however if I activate it, I have to use it for all my images, if not it will remove the other images…Is there a way to use it only for a few images and not all the images in my blog ?

    thank you for your reply

    • http://maff.ailoo.net/ Mathias

      At the moment it operates on any images it finds. Maybe I’ll add an option to select just specific images (e.g. by specifying a CSS class), but at the moment it will operate on all images.

  • http://www.superprofenchine.com/wp/ Arnauld

    very nice plugin, thanks, however if I activate it, I have to use it for all my images, if not it will remove the other images…Is there a way to use it only for a few images and not all the images in my blog ?

    thank you for your reply

    • http://maff.ailoo.net/ Mathias

      At the moment it operates on any images it finds. Maybe I’ll add an option to select just specific images (e.g. by specifying a CSS class), but at the moment it will operate on all images.

  • http://www.superprofenchine.com/wp/ Arnauld

    @Mathias ok, thank you :-)

  • http://www.superprofenchine.com/wp/ Arnauld

    @Mathias ok, thank you :-)

  • Pingback: 10 nya WordPress Plugin v17-09 | ZtrixQ.se()

  • Jonas

    Hi,
    Like Ben I’d love autothumb to work on the first image of a post. Unlike Ben I’m unfortunately near-total clueless about PHP. I have both autothumb and “Get The Image” installed (I also have the function mentioned at http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it).

    Now would anyone take pity and show me what to do in my WP template…?

    Thanks a lot!

    • http://maff.ailoo.net/ Mathias

      @Jonas using the function from your link something like this should do the trick:

      “`php
      first image
      “`

      Hope this helps,
      Mathias

  • Jonas

    Hi,
    Like Ben I’d love autothumb to work on the first image of a post. Unlike Ben I’m unfortunately near-total clueless about PHP. I have both autothumb and “Get The Image” installed (I also have the function mentioned at http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it).

    Now would anyone take pity and show me what to do in my WP template…?

    Thanks a lot!

    • http://maff.ailoo.net/ Mathias

      @Jonas using the function from your link something like this should do the trick:

      “`php

      Jonas

      Mathias,

      I got it to work with <img src="" /> (with somebody’s help) and I believe that’s exactly what you suggest. So thanks a lot for helping.

    • Jonas

      Mathias,

      I got it to work with <img src="" /> (with somebody’s help) and I believe that’s exactly what you suggest. So thanks a lot for helping.

    • Jonas

      Err… that is: I got it to work exactly as you suggested :-)

    • Jonas

      Err… that is: I got it to work exactly as you suggested :-)

    • http://www.adverbox.com neuville

      Hello, nice plugin.

      I can’t get it to work, also using Jonas hack. I’m using the <img src=”” alt=”first image” /> trick, but no image is displayed, and if I get the image url the server returns a misconfigurations.

      I’ve also tried to give 777 permission to cache and config in the phpthumb folder, with no changes. Am I missing anything? I’d like to use this to get rid of the post-thumb revisited plugin (I’ve read it was marked as spam…)

      Can you please help me?

      Another question: if I get it working, will the created images be cached or will the plugin build them each time on the fly?

      thanks a lot again, ciao!

    • http://www.adverbox.com neuville

      Hello, nice plugin.

      I can’t get it to work, also using Jonas hack. I’m using the <img src=”” alt=”first image” /> trick, but no image is displayed, and if I get the image url the server returns a misconfigurations.

      I’ve also tried to give 777 permission to cache and config in the phpthumb folder, with no changes. Am I missing anything? I’d like to use this to get rid of the post-thumb revisited plugin (I’ve read it was marked as spam…)

      Can you please help me?

      Another question: if I get it working, will the created images be cached or will the plugin build them each time on the fly?

      thanks a lot again, ciao!

    • Neal

      I am getting an error when I use this plugin. I have set the password using the settings page. I get a colored box that states:

      phpThumb() v1.7.9-200805132119
      ERROR: invalid hash

      This is the code I use in my template:

      <img src="<?php echo getphpthumburl('', 'h=90&w=90&zc=1'); ?>" alt="my resized image" />

      I have tested the catch_that_image() function and it is returning the correct path to the image. For example: /wp-content/uploads/2009/03/golden-parachute.thumbnail.jpg

      Any help would be appreciated.

    • Neal

      I am getting an error when I use this plugin. I have set the password using the settings page. I get a colored box that states:

      phpThumb() v1.7.9-200805132119
      ERROR: invalid hash

      This is the code I use in my template:

      <img src="<?php echo getphpthumburl('', 'h=90&w=90&zc=1'); ?>" alt="my resized image" />

      I have tested the catch_that_image() function and it is returning the correct path to the image. For example: /wp-content/uploads/2009/03/golden-parachute.thumbnail.jpg

      Any help would be appreciated.

    • Neal

      hmmmmm I just noticed that when I pasted the code that I use in my template it said: <img src=”<?php echo getphpthumburl(”, ‘h=90&w=90&zc=1′); ?>” alt=”my resized image” />

      It looks like the catch_that_image function actually evaluated to ”

    • Neal

      hmmmmm I just noticed that when I pasted the code that I use in my template it said: <img src=”<?php echo getphpthumburl(”, ‘h=90&w=90&zc=1′); ?>” alt=”my resized image” />

      It looks like the catch_that_image function actually evaluated to ”

    • Neal

      <img src="<?php echo getphpthumburl('', 'h=90&w=90&zc=1'); ?>" alt="my resized image" />

    • Neal

      <img src="<?php echo getphpthumburl('', 'h=90&w=90&zc=1'); ?>" alt="my resized image" />

    • http://www.punctmac.ro daniel

      I have installed the plug in and apparently is working. I say apparently because it generates the thumbs and sometimes the load and I can see the picture I refresh the page and the image is not shown. If I look inside the html code and I copy paste the url src of the image in the browser I can see the picture. It is strange because the log file of apache says that first time the page loads I get an 403 error the second time I use directly the URL i don’t get the error. I am the only one with this type o problem ??
      Thanks

      • http://maff.ailoo.net/ Mathias

        Hmm, never got such problems with phpThumb. Have your got some kind of special Apache config? Does that happen in every browser or just in particular ones?

    • http://www.punctmac.ro daniel

      I have installed the plug in and apparently is working. I say apparently because it generates the thumbs and sometimes the load and I can see the picture I refresh the page and the image is not shown. If I look inside the html code and I copy paste the url src of the image in the browser I can see the picture. It is strange because the log file of apache says that first time the page loads I get an 403 error the second time I use directly the URL i don’t get the error. I am the only one with this type o problem ??
      Thanks

      • http://maff.ailoo.net/ Mathias

        Hmm, never got such problems with phpThumb. Have your got some kind of special Apache config? Does that happen in every browser or just in particular ones?

    • http://www.betterlife99.com Kriengkrai

      Is it possible to make a link and display a photo in next window with this plugin? for example <a href=”—autothumb produce an image w=1024 and h=768—” rel=”nofollow”>1024×768</a> or <a href=”—autothumb produce an image w=800 and h=600—” rel=”nofollow”>800×600</a>

      • http://maff.ailoo.net/ Mathias

        What do you mean with in next window?

    • http://www.betterlife99.com Kriengkrai

      Is it possible to make a link and display a photo in next window with this plugin? for example <a href=”—autothumb produce an image w=1024 and h=768—” rel=”nofollow”>1024×768</a> or <a href=”—autothumb produce an image w=800 and h=600—” rel=”nofollow”>800×600</a>

      • http://maff.ailoo.net/ Mathias

        What do you mean with in next window?

    • http://www.betterlife99.com Kriengkrai
      • http://maff.ailoo.net/ Mathias

        Sure, just see here.

        — Mathias

    • http://www.betterlife99.com Kriengkrai
      • http://maff.ailoo.net/ Mathias

        Sure, just see here.

        — Mathias

    • http://roxti.com/ Wagner Reis

      One problem
      When I put one imagem from the tab Library they dont make the thumb.

      Do you know how solve?
      Se my blog you will see.

      • http://maff.ailoo.net/ Mathias

        I’m afraid I don’t understand your question, please try to re-formulate it. When looking at your blog I see squared thumbs which are generated with phpThumb.

      • http://roxti.com/ Wagner Reis

        If i upload one new image they works fine.

        If a use one image from media library (thrid tab of upload in wordpress) the phpThumb dont generate the Thumb

      • http://maff.ailoo.net/ Mathias

        How do you insert your media? With an img-tag or with WordPress’ gallery system?

    • http://roxti.com/ Wagner Reis

      One problem
      When I put one imagem from the tab Library they dont make the thumb.

      Do you know how solve?
      Se my blog you will see.

      • http://maff.ailoo.net/ Mathias

        I’m afraid I don’t understand your question, please try to re-formulate it. When looking at your blog I see squared thumbs which are generated with phpThumb.

      • http://roxti.com/ Wagner Reis

        If i upload one new image they works fine.

        If a use one image from media library (thrid tab of upload in wordpress) the phpThumb dont generate the Thumb

      • http://maff.ailoo.net/ Mathias

        How do you insert your media? With an img-tag or with WordPress’ gallery system?

    • http://roxti.com/ Wagner Reis

      http://img223.imageshack.us/img223/9997/autothumb.jpg when i use some image in this tab.

      The your idea for this plugin is bug, bug i think they is very complex, he creates a url inside the post why? I need only whem I use the function.

      I remove your plugin, i hope he is better and future I tested it again.

      I made one, I put one simple funcition to get the first image and used the phpThumb or timthumb too

    • http://roxti.com/ Wagner Reis

      http://img223.imageshack.us/img223/9997/autothumb.jpg when i use some image in this tab.

      The your idea for this plugin is bug, bug i think they is very complex, he creates a url inside the post why? I need only whem I use the function.

      I remove your plugin, i hope he is better and future I tested it again.

      I made one, I put one simple funcition to get the first image and used the phpThumb or timthumb too

    • http://roxti.com/ Wagner Reis

      And the phpThumb dont get external images I do not know why, i will make one function to donwload the external imagem in my cache folder then used in phpThumb , this site has one class, i will try
      http://www.bitrepository.com/download-image.html

      • http://maff.ailoo.net/ Mathias

        AutoThumb/phpThumb is capable of handling external images via http. If you can do that, depends on your PHP config (allow_url_fopen I think).

      • Paul

        I have url_fopen on and it it doesn’t seem to be able to get the images. I’ve also set the array of valid no hot link domains. Any ideas why it’s not working?

      • Paul

        Hey Guys

        I debugged the issue with external images. The if statement that checks whether the image is on the server or not a had a couple of errors in it.

        // trim URL when it points to the same host
        if($wordpress_url['host'] == $image_url['host']) {
        $image = $image_url['path'];
        $httpSrc = false;
        } else {
        // encode the link so phpthumb can use the remote image
        $image = rawurlencode($image);
        $httpSrc = true;
        }

        Hope that helps everyone and Mathias can update the plugin on WordPress soon because this plugin is awesome.

        Cheers,
        Paul

    • http://roxti.com/ Wagner Reis

      And the phpThumb dont get external images I do not know why, i will make one function to donwload the external imagem in my cache folder then used in phpThumb , this site has one class, i will try
      http://www.bitrepository.com/download-image.html

      • http://maff.ailoo.net/ Mathias

        AutoThumb/phpThumb is capable of handling external images via http. If you can do that, depends on your PHP config (allow_url_fopen I think).

      • Paul

        I have url_fopen on and it it doesn’t seem to be able to get the images. I’ve also set the array of valid no hot link domains. Any ideas why it’s not working?

      • Paul

        Hey Guys

        I debugged the issue with external images. The if statement that checks whether the image is on the server or not a had a couple of errors in it.

        // trim URL when it points to the same host
        if($wordpress_url['host'] == $image_url['host']) {
        $image = $image_url['path'];
        $httpSrc = false;
        } else {
        // encode the link so phpthumb can use the remote image
        $image = rawurlencode($image);
        $httpSrc = true;
        }

        Hope that helps everyone and Mathias can update the plugin on WordPress soon because this plugin is awesome.

        Cheers,
        Paul

    • bonsak

      Hi
      Great plugin. But do you have any idea why i get this warning (in the console) when useing the plugin with MAMP on a local machine:
      [28-Jul-2009 14:40:54] PHP Warning: fopen(http://localhost/racecar/wp-content/uploads/2009/07/nrk-super-hoppe.jpg) [function.fopen]: failed to open stream: Connection refused in /Applications/MAMP/htdocs/racecar/wp-content/plugins/autothumb/phpthumb/phpthumb.functions.php on line 796
      For me it seems its looking for the image in the wrong url. http://localhost/racecar/wp-content/uploads/2009/07/nrk-super-hoppe.jpg
      It should be looking under http://localhost:8888/... Do you have any idea why the portnumbers are truncated?

      Kind Regards
      Bonsak

      • http://maff.ailoo.net/ Mathias

        Hmm to be honest I never tried the plugin with different port numbers than 80, might be that the plugin causes this problem and truncates the port number. I’ll check this and notify you if there are any updates.

    • bonsak

      Hi
      Great plugin. But do you have any idea why i get this warning (in the console) when useing the plugin with MAMP on a local machine:
      [28-Jul-2009 14:40:54] PHP Warning: fopen(http://localhost/racecar/wp-content/uploads/2009/07/nrk-super-hoppe.jpg) [function.fopen]: failed to open stream: Connection refused in /Applications/MAMP/htdocs/racecar/wp-content/plugins/autothumb/phpthumb/phpthumb.functions.php on line 796
      For me it seems its looking for the image in the wrong url. http://localhost/racecar/wp-content/uploads/2009/07/nrk-super-hoppe.jpg
      It should be looking under http://localhost:8888/... Do you have any idea why the portnumbers are truncated?

      Kind Regards
      Bonsak

      • http://maff.ailoo.net/ Mathias

        Hmm to be honest I never tried the plugin with different port numbers than 80, might be that the plugin causes this problem and truncates the port number. I’ll check this and notify you if there are any updates.

    • bonsak

      Cool, thanks.

      • http://maff.ailoo.net/ Mathias

        I released version 0.4 (just tagged 0.4.3) yesterday, which works without problems on URLs with port numbers. Plus, I added some more features and improved the options page (just re-read this page, I updated the content).

        — Mathias

      • bonsak

        Great, ill try it out.

    • bonsak

      Cool, thanks.

      • http://maff.ailoo.net/ Mathias

        I released version 0.4 (just tagged 0.4.3) yesterday, which works without problems on URLs with port numbers. Plus, I added some more features and improved the options page (just re-read this page, I updated the content).

        — Mathias

      • bonsak

        Great, ill try it out.

    • neuville

      Hello,
      I’ll try the new release (maybe it will solve the probs on my server)

      A couple of question:
      1) is there a way to get thumbs for youtube videos?
      2) is there a way to generate a default thumb if no images are in the post?

      thanks for your support,
      ciao!

      • Mathias

        Hi,

        ad 1) As far as I know, phpThumb has no option for that, no.
        ad 2) How do you mean that? Have you some sort of image header in your posts?

        Edit: oh sorry, just saw your other comment. Do you have GD installed on your server and does phpThumb itself work (there is a demo script you can download along with the original package)? The image header thing is more a template related issue, I use custom fields to display a post image. Example: my custom content function to display the_content() together with images set as custom fields (I call that function instead of the_content() in my templates). You can see it live here.

        “`php
        function ml_the_content()
        {
        global $post, $wpdb;
        $meta = get_post_custom($post->ID);

        if(isset($meta[‘postimage’]) && is_array($meta[‘postimage’]) && count($meta[‘postimage’] > 0)) {
        $i = 0;
        foreach($meta[‘postimage’] as $image) {
        echo ‘‘;
        echo ”;
        echo ‘
        ‘;
        echo “n”;
        ++$i;
        }
        }

        the_content();
        }
        “`

        You can easily adapt the function to use a default image if there are no custom fields set (or adapt the first image function you are using now).

        — Mathias

    • neuville

      Hello,
      I’ll try the new release (maybe it will solve the probs on my server)

      A couple of question:
      1) is there a way to get thumbs for youtube videos?
      2) is there a way to generate a default thumb if no images are in the post?

      thanks for your support,
      ciao!

      • Mathias

        Hi,

        ad 1) As far as I know, phpThumb has no option for that, no.
        ad 2) How do you mean that? Have you some sort of image header in your posts?

        Edit: oh sorry, just saw your other comment. Do you have GD installed on your server and does phpThumb itself work (there is a demo script you can download along with the original package)? The image header thing is more a template related issue, I use custom fields to display a post image. Example: my custom content function to display the_content() together with images set as custom fields (I call that function instead of the_content() in my templates). You can see it live here.

        “`php
        function ml_the_content()
        {
        global $post, $wpdb;
        $meta = get_post_custom($post->ID);

        if(isset($meta[‘postimage’]) && is_array($meta[‘postimage’]) && count($meta[‘postimage’] > 0)) {
        $i = 0;
        foreach($meta[‘postimage’] as $image) {
        echo ‘

        ‘;
        echo ‘' . the_title_attribute('echo=0') . '‘;
        echo ‘

        ‘;
        echo “\n”;
        ++$i;
        }
        }

        the_content();
        }
        “`

        You can easily adapt the function to use a default image if there are no custom fields set (or adapt the first image function you are using now).

        — Mathias

    • http://www.adverbox.com neuville

      Hello Mathias,
      thanks for the reply and forgive the delay, I’ve been out of home.

      So, I’ve tried some solutions listed below but I still can’t get this to work :-(

      1) change permissions of all files and folders to 755 in the plugin: this way I can get something working
      2) don’t using shortcodes: I’m link an image directly to the image.php file; this is returning an error: missing hash, and a 400×100 black image
      3) linking an image directly to the phpThumb.php file; same error as above
      4) the shortcodes provided (echo getphpthumburl) just call the root of my website (ww.adverbox.com)
      5) you can see an example following: http://www.adverbox.com/admin/wordpress/wp-content/plugins/autothumb/image.php?src=http://www.adverbox.com/admin/wordpress/wp-content/uploads/members-media/4909//Meatball_scented_ads-480×150.jpg&w=200 (hope it will work

      thanks for your time, ciao!

    • http://www.adverbox.com neuville

      Hello Mathias,
      thanks for the reply and forgive the delay, I’ve been out of home.

      So, I’ve tried some solutions listed below but I still can’t get this to work :-(

      1) change permissions of all files and folders to 755 in the plugin: this way I can get something working
      2) don’t using shortcodes: I’m link an image directly to the image.php file; this is returning an error: missing hash, and a 400×100 black image
      3) linking an image directly to the phpThumb.php file; same error as above
      4) the shortcodes provided (echo getphpthumburl) just call the root of my website (ww.adverbox.com)
      5) you can see an example following: http://www.adverbox.com/admin/wordpress/wp-content/plugins/autothumb/image.php?src=http://www.adverbox.com/admin/wordpress/wp-content/uploads/members-media/4909//Meatball_scented_ads-480×150.jpg&w=200 (hope it will work

      thanks for your time, ciao!

    • Ben

      Hi Mathias, first time I’ve looked at this plugin since you added the rewrite capabilities – nice.

      One thing I’ve noticed, it seems to rewrite the src using the full URL (as the image links in posts are saved with full URLs not relative ones) eg I’m getting extended image paths like

      http://example.com/ben_images/http://example.com/wp-content/uploads/2009/08/Meet5.jpg?w=480&h=480&aoe=1&q=100&hash=a52ff101d29ee1012813b7127df17722

      instead of

      http://example.com/ben_images/wp-content/uploads/2009/08/Meet5.jpg?w=480&h=480&aoe=1&q=100&hash=a52ff101d29ee1012813b7127df17722

      where ben_images is my rewrite base path.

      I think in the autothumb() filter on the_content you could build shorter URLs by stripping the blog path from the string if its found.

      A couple of other option related suggestions from my use of this on a few blogs as well:

      1. The default jpg quality is set to 75 in the phpthumb.class.php, I find this to be way to pixelated on most images (particularly on ones with text or flat vector generated colours) and normally bump it to 80 ~ 85, it would be great to have that in the options panel.

      2. An option to enable Zoom Crop by default on images would probably be useful to a lot of people, if you have a theme with rigid size limits and a mix of portrait and landscape images it comes in very handy

      3. Don’t know how useful this one would be, but controlling the error image from the options panel might be good, the default phpthumb error image is very useful during development, but an eyesore on a production site.

      • http://maff.ailoo.net/ Mathias

        Hi Ben,

        thanks for your Feedback. I fixed the issue with the full URLs – path gets stripped now when the URL points to the same Host. Your other comments:

        1. I noticed this issue too and set the default quality to 100 since version 0.4. If I got a bit more time I’ll add an option for this in the option panel.

        2. You’re right, I use zc almost all the time. I’ll add a parameter for default options to the autothumb function + a setting in the option panel.

        3. I’d suggest just editing the phpthumb configuration file to achieve this. However, I’ll think about a solution which doesn’t overwrite the config file on a plugin update.

        — Mathias

    • Ben

      Hi Mathias, first time I’ve looked at this plugin since you added the rewrite capabilities – nice.

      One thing I’ve noticed, it seems to rewrite the src using the full URL (as the image links in posts are saved with full URLs not relative ones) eg I’m getting extended image paths like

      http://example.com/ben_images/http://example.com/wp-content/uploads/2009/08/Meet5.jpg?w=480&h=480&aoe=1&q=100&hash=a52ff101d29ee1012813b7127df17722

      instead of

      http://example.com/ben_images/wp-content/uploads/2009/08/Meet5.jpg?w=480&h=480&aoe=1&q=100&hash=a52ff101d29ee1012813b7127df17722

      where ben_images is my rewrite base path.

      I think in the autothumb() filter on the_content you could build shorter URLs by stripping the blog path from the string if its found.

      A couple of other option related suggestions from my use of this on a few blogs as well:

      1. The default jpg quality is set to 75 in the phpthumb.class.php, I find this to be way to pixelated on most images (particularly on ones with text or flat vector generated colours) and normally bump it to 80 ~ 85, it would be great to have that in the options panel.

      2. An option to enable Zoom Crop by default on images would probably be useful to a lot of people, if you have a theme with rigid size limits and a mix of portrait and landscape images it comes in very handy

      3. Don’t know how useful this one would be, but controlling the error image from the options panel might be good, the default phpthumb error image is very useful during development, but an eyesore on a production site.

      • http://maff.ailoo.net/ Mathias

        Hi Ben,

        thanks for your Feedback. I fixed the issue with the full URLs – path gets stripped now when the URL points to the same Host. Your other comments:

        1. I noticed this issue too and set the default quality to 100 since version 0.4. If I got a bit more time I’ll add an option for this in the option panel.

        2. You’re right, I use zc almost all the time. I’ll add a parameter for default options to the autothumb function + a setting in the option panel.

        3. I’d suggest just editing the phpthumb configuration file to achieve this. However, I’ll think about a solution which doesn’t overwrite the config file on a plugin update.

        — Mathias

    • Jason

      Will this do everything that phpThumb does, specifically rounding corners and stuff? That’s what I really need it for; if not, is it easy to modify to incorporate that functionality?

      • http://maff.ailoo.net/ Mathias

        Yep, parameters are directly passed to phpThumb. I added an example above.

        — Mathias

    • Jason

      Will this do everything that phpThumb does, specifically rounding corners and stuff? That’s what I really need it for; if not, is it easy to modify to incorporate that functionality?

      • http://maff.ailoo.net/ Mathias

        Yep, parameters are directly passed to phpThumb. I added an example above.

        — Mathias

    • Jason

      Hmm…can’t seem to get it working. I chmoded both the cache folder and the phpThumb.config.php file to 755. :-(

    • Jason

      Hmm…can’t seem to get it working. I chmoded both the cache folder and the phpThumb.config.php file to 755. :-(

    • Jason

      More info: basically I’ve done the chmodding as stated above but no matter what I pass as arguments after the image, like ?w=400&fltr[]=ric|30|30&fltr[]=sat|-100&fltr[]=cont|30&f=png, etc. the image just stays the same as it was before. No error message, nothing.

      I’ve tried with just a normal image tag in the HTML, but I want to eventually get this to work with NextGEN Gallery.

      I’m using WordPress MU 2.8.4a also…I’m going to keep trying things; I’ll post back here if I get it to work.

    • Jason

      More info: basically I’ve done the chmodding as stated above but no matter what I pass as arguments after the image, like ?w=400&fltr[]=ric|30|30&fltr[]=sat|-100&fltr[]=cont|30&f=png, etc. the image just stays the same as it was before. No error message, nothing.

      I’ve tried with just a normal image tag in the HTML, but I want to eventually get this to work with NextGEN Gallery.

      I’m using WordPress MU 2.8.4a also…I’m going to keep trying things; I’ll post back here if I get it to work.

    • Jason

      I’ve started using the
      <img src="” />
      way of doing things and it seems to be working fine now :-)

    • Jason

      I’ve started using the
      <img src="” />
      way of doing things and it seems to be working fine now :-)

    • Jason

      Oops, my code got sanatized…
      what I meant to write was, in the tag, for src attribute, I put:

    • Jason

      Oops, my code got sanatized…
      what I meant to write was, in the tag, for src attribute, I put:
      [?php echo getphpthumburl(‘wp-content/themes/default/images/photo4.jpg’, ‘w=400&fltr[]=ric|30|30&fltr[]=sat|-100&fltr[]=cont|30&f=png’); ?]

    • Jason

      Oops, my code got sanatized…
      what I meant to write was, in the tag, for src attribute, I put:

    • Jason

      Oops, my code got sanatized…
      what I meant to write was, in the tag, for src attribute, I put:
      [?php echo getphpthumburl(‘wp-content/themes/default/images/photo4.jpg’, ‘w=400&fltr[]=ric|30|30&fltr[]=sat|-100&fltr[]=cont|30&f=png’); ?]

    • Ben

      Hi Mathias,

      Just spotted a bug but haven’t traced it through yet – posting this before I forget – the rewrite rules don’t appear to get updated when you change your permalink structure.

      Here’s how to repeat the bug (and how to work around it).
      Start with a clean install and Authothumb clean URLs off.

      1. Set your permalink structure to /%year%/%monthnum%/%postname%/
      2. Now turn on Autothumb clean URLs
      3. Verfiy that its working
      4. Change your permalink structure to /archives/%post_id%
      5. Autothumbs no longer work
      6. Turn off Autothumb clean URLs and save
      7. Turn them back on again
      8. Autothumbs work again

      The actual permalink structures don’t matter, its the change that doesn’t get captured and triggers the bug.

    • Ben

      Hi Mathias,

      Just spotted a bug but haven’t traced it through yet – posting this before I forget – the rewrite rules don’t appear to get updated when you change your permalink structure.

      Here’s how to repeat the bug (and how to work around it).
      Start with a clean install and Authothumb clean URLs off.

      1. Set your permalink structure to /%year%/%monthnum%/%postname%/
      2. Now turn on Autothumb clean URLs
      3. Verfiy that its working
      4. Change your permalink structure to /archives/%post_id%
      5. Autothumbs no longer work
      6. Turn off Autothumb clean URLs and save
      7. Turn them back on again
      8. Autothumbs work again

      The actual permalink structures don’t matter, its the change that doesn’t get captured and triggers the bug.

    • Ben

      Hi again Mathias,
      I’ve traced that bug through now, there’s a couple of ways to fix it – my thoughts are to add an extra function to the plugin that hooks onto the generate_rewrite_rules action.

      I’ve done a little bit of testing with this on a single wp2.8.4 apache install and it seems to work ok

      extra function:

      /**
      * autothumb_generate_rewrite_action
      *
      * 06/09/09 Ben - Added Extra action to ensure autothumb rewrite's are not-overwritten when
      * WordPress updates its permalink/category rules
      * @param object $wp_rewrite Reference to the global wp_rewrite object
      */
      function autothumb_generate_rewrite_action($wp_rewrite)
      {
      $switch = get_option('autothumb_clean_urls');
      $path = get_option('autothumb_clean_urls_path');

      if($switch == 1 && $path !== false && !empty($path)) {
      $wp_rewrite->non_wp_rules[$path . '/(.*)$'] = 'wp-content/plugins/autothumb/image.php?$1';
      }
      }

      And then the action hook is:

      add_action('generate_rewrite_rules','autothumb_generate_rewrite_action');

      This respects any other plugins that have added their own non_wp_rules, it just appends the extra rule – however I’ve noticed that a lot of examples of using non_wp_rules don’t append the array, they instead overwrite it, so other plugins may or may not cause problems depending on how defensively they have been written.

      A second approach I tried was to add a filter to mod_rewrite_rules – this way you can catch the .htaccess rules as a string and add your own immediately before the wp generated rules are written. This lets you completely insulate yourself from any other plugins, but you then have to rebuild the RewriteBase as well – it just felt messier.

      One problem remains however, the current phpThumb approach means that if you link images to Facebook or similar sites (eg you use Addthis/Sharethis or someone just adds a post on their wall) it breaks as Facebook scrambles the hash in the querystring (or something like that). You can post the link ok, but when you go to view it facebook has ‘cleaned’ the url to the image.

      Somehow I need to get the actual image path for the cached auto generated image once it has been created, rather they running through phpThumb to check for its existance.

      Something a bit like this http://mrphp.com.au/code/project/miscellaneous/image-cache-using-phpthumb-and-htaccess, but that’s still open to abuse by external scripts…any ideas?

      • http://maff.ailoo.net/ Mathias

        Hi Ben,

        sorry for my late response but I’m quite busy at the moment as I’m currently moving to Spain for an exchange semester. As of this, I don’t know how much time I can spend in the next weeks on maintaining the plugin. If you like I could add you as commiter to the SVN-Repo, would be easier than handling around with patches ;) Just drop me an email if you are interested (you can find my address on the about page).

        — Mathias

    • Ben

      Hi again Mathias,
      I’ve traced that bug through now, there’s a couple of ways to fix it – my thoughts are to add an extra function to the plugin that hooks onto the generate_rewrite_rules action.

      I’ve done a little bit of testing with this on a single wp2.8.4 apache install and it seems to work ok

      extra function:

      /**
      * autothumb_generate_rewrite_action
      *
      * 06/09/09 Ben - Added Extra action to ensure autothumb rewrite's are not-overwritten when
      * WordPress updates its permalink/category rules
      * @param object $wp_rewrite Reference to the global wp_rewrite object
      */
      function autothumb_generate_rewrite_action($wp_rewrite)
      {
      $switch = get_option('autothumb_clean_urls');
      $path = get_option('autothumb_clean_urls_path');

      if($switch == 1 && $path !== false && !empty($path)) {
      $wp_rewrite->non_wp_rules[$path . '/(.*)$'] = 'wp-content/plugins/autothumb/image.php?$1';
      }
      }

      And then the action hook is:

      add_action('generate_rewrite_rules','autothumb_generate_rewrite_action');

      This respects any other plugins that have added their own non_wp_rules, it just appends the extra rule – however I’ve noticed that a lot of examples of using non_wp_rules don’t append the array, they instead overwrite it, so other plugins may or may not cause problems depending on how defensively they have been written.

      A second approach I tried was to add a filter to mod_rewrite_rules – this way you can catch the .htaccess rules as a string and add your own immediately before the wp generated rules are written. This lets you completely insulate yourself from any other plugins, but you then have to rebuild the RewriteBase as well – it just felt messier.

      One problem remains however, the current phpThumb approach means that if you link images to Facebook or similar sites (eg you use Addthis/Sharethis or someone just adds a post on their wall) it breaks as Facebook scrambles the hash in the querystring (or something like that). You can post the link ok, but when you go to view it facebook has ‘cleaned’ the url to the image.

      Somehow I need to get the actual image path for the cached auto generated image once it has been created, rather they running through phpThumb to check for its existance.

      Something a bit like this http://mrphp.com.au/code/project/miscellaneous/image-cache-using-phpthumb-and-htaccess, but that’s still open to abuse by external scripts…any ideas?

      • http://maff.ailoo.net/ Mathias

        Hi Ben,

        sorry for my late response but I’m quite busy at the moment as I’m currently moving to Spain for an exchange semester. As of this, I don’t know how much time I can spend in the next weeks on maintaining the plugin. If you like I could add you as commiter to the SVN-Repo, would be easier than handling around with patches ;) Just drop me an email if you are interested (you can find my address on the about page).

        — Mathias

    • Ben

      Hi Mathias – sent you an email.

    • Ben

      Hi Mathias – sent you an email.

    • Pingback: Fusion theme for Wordpress Personal Blog()

    • Michael

      I’m sorry, i need some help. I have read the past posts here but i don’t understand. I hope you can help me.

      i have in my posts images like this http://ts.vimeo.com.s3.amazonaws.com/230/309/23030964_200.jpg
      when i turn autothumb on i get an ‘error-image’ (the light blue ones) saying image missing. that is right because the http:// and domain whole domains gets truncated.

      how to fix this? or why this part gets cut off?
      thx you

    • Michael

      I’m sorry, i need some help. I have read the past posts here but i don’t understand. I hope you can help me.

      i have in my posts images like this http://ts.vimeo.com.s3.amazonaws.com/230/309/23030964_200.jpg
      when i turn autothumb on i get an ‘error-image’ (the light blue ones) saying image missing. that is right because the http:// and domain whole domains gets truncated.

      how to fix this? or why this part gets cut off?
      thx you

    • http://hildersantos.com Hilder Santos

      Hi, Mathias!

      I found a little issue in your plugin: it’s not getting external images and applying the PHPThumb, because it’s resolving it like internal images (from same domain).

      Doing a little search at your code, I found that there’s an error in a conditional at line 54, to be more precisely:

      “`php
      if($wordpress_url[‘hostname’] == $image_url[‘hostname’]) {
      “`

      There’s no “hostname” on parse_url() function… But there’s “host”! :D

      So, the correct code should be:

      “`php
      if($wordpress_url[‘host’] == $image_url[‘host’]) {
      “`

      And all is done. ^^

      May you take look at this and correct your awesome plugin for us? :D

      Thank you, man!

      • http://maff.ailoo.net/ Mathias

        Hi Hilder!

        Thank you for the bugfix, I just corrected it and tagged it as version 0.5.2 (should be available in a few minutes in the WP plugins repository).

        — Mathias

    • http://hildersantos.com Hilder Santos

      Hi, Mathias!

      I found a little issue in your plugin: it’s not getting external images and applying the PHPThumb, because it’s resolving it like internal images (from same domain).

      Doing a little search at your code, I found that there’s an error in a conditional at line 54, to be more precisely:

      “`php
      if($wordpress_url[‘hostname’] == $image_url[‘hostname’]) {
      “`

      There’s no “hostname” on parse_url() function… But there’s “host”! :D

      So, the correct code should be:

      “`php
      if($wordpress_url[‘host’] == $image_url[‘host’]) {
      “`

      And all is done. ^^

      May you take look at this and correct your awesome plugin for us? :D

      Thank you, man!

      • http://maff.ailoo.net/ Mathias

        Hi Hilder!

        Thank you for the bugfix, I just corrected it and tagged it as version 0.5.2 (should be available in a few minutes in the WP plugins repository).

        — Mathias

    • http://fractured-state.com Paul Sheldrake

      Hi Mathias

      The new version (0.5.2) doesn’t seem to be encoding the URL properly. I’ve had a wrap the link to the picture link in rawurlencode to get it to work. In the last version the plugin worked without me having to do this.

      I commented about a fix for the off server links a little while ago which should also fix this problem as well.

      http://maff.ailoo.net/2008/07/wordpress-plugin-autothumb-phpthumb/#comment-3636

      Cheers,
      Paul

    • http://fractured-state.com Paul Sheldrake

      Hi Mathias

      The new version (0.5.2) doesn’t seem to be encoding the URL properly. I’ve had a wrap the link to the picture link in rawurlencode to get it to work. In the last version the plugin worked without me having to do this.

      I commented about a fix for the off server links a little while ago which should also fix this problem as well.

      http://maff.ailoo.net/2008/07/wordpress-plugin-autothumb-phpthumb/#comment-3636

      Cheers,
      Paul

    • moe

      Hi,

      I’m a newbie, but How it works?

      I installed the plugin, enter the password, and…?

      http://www.ultragraphik.com/histoirecourte/

      As you can see, no “avatar”, it don’t works..

      The 2 or 3 thumbails you can see on the site, are host on my serveur ( the custom fields: Image),
      But, I thougt it possible to make a thumb from the first pic on my page, even if the image was an external image, hosted by amazon.com, in my example..

      Help!!

    • moe

      Hi,

      I’m a newbie, but How it works?

      I installed the plugin, enter the password, and…?

      http://www.ultragraphik.com/histoirecourte/

      As you can see, no “avatar”, it don’t works..

      The 2 or 3 thumbails you can see on the site, are host on my serveur ( the custom fields: Image),
      But, I thougt it possible to make a thumb from the first pic on my page, even if the image was an external image, hosted by amazon.com, in my example..

      Help!!

    • Chris

      Hi this is great..I used it on a site recently with custom fields with some code supplied from this site and it worked just great. Am having trouble with it working with my account however..

      Half way down page I am getting an error message related to file path..Advice much appreciated.

      Here is the path I am getting …I contact webhost and they told me to modify path in post area which is not ideal..There muct be a way to modify plugin files to make this work?

    • Chris

      Hi this is great..I used it on a site recently with custom fields with some code supplied from this site and it worked just great. Am having trouble with it working with my account however..

      Half way down page I am getting an error message related to file path..Advice much appreciated.

      Here is the path I am getting …I contact webhost and they told me to modify path in post area which is not ideal..There must be a way to modify plugin files to make this work?

    • Chris

      Hi this is great..I used it on a site recently with custom fields with some code supplied from this site and it worked just great. Am having trouble with it working with my account however..

      Half way down page I am getting an error message related to file path..Advice much appreciated.

      Here is the path I am getting …I contact webhost and they told me to modify path in post area which is not ideal..There muct be a way to modify plugin files to make this work?

    • Chris

      Hi this is great..I used it on a site recently with custom fields with some code supplied from this site and it worked just great. Am having trouble with it working with my account however..

      Half way down page I am getting an error message related to file path..Advice much appreciated.

      Here is the path I am getting …I contact webhost and they told me to modify path in post area which is not ideal..There must be a way to modify plugin files to make this work?

    • Aliakbar

      Hi,
      How can I make the screen go dark instead of white when I click a picture? And how can I change the font size on photo’s caption?

      Thanks in advance. Good plugin.

      • http://fractured-state.com Paul

        Hi Aliakbar

        This plugin doesn’t have anything to do with how photos react when you click them, that is handled by another plugin you have installed.

        Sorry.

        -Paul

    • Aliakbar

      Hi,
      How can I make the screen go dark instead of white when I click a picture? And how can I change the font size on photo’s caption?

      Thanks in advance. Good plugin.

      • http://fractured-state.com Paul

        Hi Aliakbar

        This plugin doesn’t have anything to do with how photos react when you click them, that is handled by another plugin you have installed.

        Sorry.

        -Paul

    • http://www.creativeglo.co.uk James

      Hi, I’ve been using this excellent plugin for a while now. Only just realised the power of switching on ‘Apply Autothumb on post/page content?’. What a fantastic feature. Just saved a ton of time!

    • http://www.creativeglo.co.uk James

      Hi, I’ve been using this excellent plugin for a while now. Only just realised the power of switching on ‘Apply Autothumb on post/page content?’. What a fantastic feature. Just saved a ton of time!

    • Damien

      Hello,
      first of all, thank you for this great plugin. Glad I found it.

      I’m using PHP Version 5.3.2, so the included phpthumb script didn’t work. I found a fix for that, http://sourceforge.net/tracker/index.php?func=detail&aid=2937928&group_id=106407&atid=643974.
      So now it worked when there was only one image in the content. When there were more images, the creation of the page was cut off at the title. Searched around in the sources and found in autothumb.php the function getphpthumburl.
      At the top of this function there is an include: include(AUTOTHUMB_PATH . 'phpthumb/phpThumb.config.php');
      After changing this to include_once(AUTOTHUMB_PATH . 'phpthumb/phpThumb.config.php'); it worked and all the images in the content are processed.

      As I am not really into php it is all to possible that with this ‘fix’ I’m breaking something else or there is another solution, but I thought I’d mention it just in case.

      Thanks again for the plugin.

    • Damien

      Hello,
      first of all, thank you for this great plugin. Glad I found it.

      I’m using PHP Version 5.3.2, so the included phpthumb script didn’t work. I found a fix for that, http://sourceforge.net/tracker/index.php?func=detail&aid=2937928&group_id=106407&atid=643974.
      So now it worked when there was only one image in the content. When there were more images, the creation of the page was cut off at the title. Searched around in the sources and found in autothumb.php the function getphpthumburl.
      At the top of this function there is an include: include(AUTOTHUMB_PATH . 'phpthumb/phpThumb.config.php');
      After changing this to include_once(AUTOTHUMB_PATH . 'phpthumb/phpThumb.config.php'); it worked and all the images in the content are processed.

      As I am not really into php it is all to possible that with this ‘fix’ I’m breaking something else or there is another solution, but I thought I’d mention it just in case.

      Thanks again for the plugin.

    • http://www.bad-fotography.co.uk/ trentrampage

      dude your plugin works fine but it’s actually creating copies of the images instead of dynamically resizing them. i just found out today that there;s like 70,000 copies of images in my server! its taking up a lot of space. what can i do to sort this out? thanks

      • http://ailoo.net Mathias

        Hey,

        yes, it creates copies of the resampled images and caches them, otherwise pageloads would be quite heavy (fetching images from filesystem/remote server and executing operations). However, the cache size was set quite high (80MB), as this was working for me and I never heard any complaints yet. I reduced it to 10MB now and committed a new version (0.5.3.2) which should be available as update soon.

        BTW: you can safely delete all contents of the cache directory…phpThumb will regenerate thumbnails on demand if cache files are missing.

        Regards,
        Mathias

        • http://www.bad-fotography.co.uk/ trentrampage

          should i delete the whole directory called “cache” or should i just delete the contents in that directory and leave the empty “cache” folder there?

          • http://ailoo.net Mathias

            I’m not 100% sure if you can safely remove the whole folder. What works for sure is to reset the cache structure to how its delivered on plugin installation:

            – cache
            — source
            — index.php
            — index.php

            So delete all contents in the cache directory except index.php and source/index.php.

            Regards,
            Mathias

          • http://www.bad-fotography.co.uk/ trentrampage

            thanks dude

          • http://www.bad-fotography.co.uk/ trentrampage

            dude is there somewhere in the code i can set to expire the cache so it will delete it after a while?

    • Joelle

      Hi, I’m using WP 3.0.4 (multisite) and the latest version of your plugin. I keep running into this issue and I hope you can help.

      It seems whenever the “High Security Password” is entered into the field and I hit save, then the images stop showing up — but not on the entire network, just one site on the network, the site where I added the security password.

      On save, all the images using Autothumb in that site show the lavender box with red text instead of the image. So every time I do an upgrade and I have to add the security password, it breaks like this. I had a friend fix it for me last time, but I’d love to know how to fix this myself.

      I hope you can help! :) Thanks!

    • http://www.facebook.com/profile.php?id=688696850 Jonathan Bloomer

      Is there a way to have autothumb set to automatically apply to post content but not to the rss feed output? At the moment the site is showing the error msg image for all images in Google Reader.

    • http://twitter.com/benz001 Ben George

      Hi Mathias – Just thought you’d like to know I’ve just had a site hacked via a
      phpThumb exploit.

      I’ve taken Autothumb and merged in the latest phpThumb release, I’ve
      not finished getting it all working properly (the clean image rewrite
      doesn’t work yet) but it at least let me get the blog up and running
      again!

      I’ve sent you an email with the link to the updated code

    • Ronald Patino

      Thanks a lot for this great plugin, I am having an issue with Super cache, whenever the cache gets refreshed autothumb wont create the images anymore. Not sure if anyone has run into the same issue?

      When I check the images they only have the image url without the phpthumb parameters.

      I am using this to generate the image

      $imagen = get_featured_image($post->ID);
      $src= getphpthumburl($imagen, ‘w=762&h=364&zc=1&q=90′);

      First time works ok, I get in the src:

      http://www.website.com/wp-content/plugins/autothumb/image.php?src=/wp-content/uploads/image.jpg&w=346&h=346&zc=1&iar=1&hash=4af7549184d53581dce5647871081dcf

      Then cache gets updated and I only get

      http://www.website.com/wp-content/uploads/image.jpg

      Any ideas.
      Thanks a lot for reading this comment

    • Pingback: Looid()