thumbGen

WordPress plugin

VERSION 2.5.3 RELEASED!!!

This plugin is made for developers. It creates a function named thumbGen() that allows to show any image in the specified size. Additionally you can specify values like crop, center, rotation and effects.

It saves all generated thumbs in a cache folder, so it won’t overload your server at all.

Download last version from WordPress repository
(or search for it on your “add plugins” page)

License

Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

Donations

Well… I put this at the begining not because I’m doing this plugin to make some money, but because this is a lot of incentive to make more plugins like this. As every developer, I will always be happy to recieve your donations for my work and it will make me happier to keep updating this plugin.


Is very easy to donate… try it!

Documentation

Installation

Just donwload the zip file, upload it to your wordpress via install plugins page (or uncompress it to your wordpress wp-content/plugins/ folder) and activate it. Once activated se the main folder and default iage (in settings/thumbGen) and the plugin is ready to be used by calling its main function (see “Usage” section below).

Requirements

This plugin has been tested under the 2.9.0+ version of  WordPress. Anyway, since this doesn’t use any wordpress function (just PHP) I thing it could work under any version of WordPress. For the grayscale function it uses th GD Library.

The generated images are saved under the cache folder specified in the config page. If you have any problem you should check your settings.

Probably this plugin will work in almost every servers. If your server doesn’t support this plugin, please check the folder configuration. Otherwise please let me know.

Usage

To use this function you just need to use this line code:

<?php thumbGen(image,width,height,additional_parameters); ?>

image: the full URL of the original image you need to create a thumbnail from (needed).
width:
the width you need for the generated thumbnail (default=0 – if not specified it gets the proportional value from the specified height).
height:
the height you need for the generated thumbnail (default=0 – if not specified it gets the proportional value from the specified width).
note: if you don’t specify the with AND height (or if you set both to 0), the image will be generated in the source size.

Additional parameters

filename: some people have troubles with duplicated names, so I’ve added this parameter for you to specify a new filename (or ID or something like that) in order to differentiate each file (if not set it will use the source filename).
md5: by default, the images are generated with an md5 encode filename. If you don’t want the generated file to have an encoded name set this to 0
force: force thumb creation, even if it already exists (default=0) (NOT RECOMENDED! – use it just for testing or debugging)
crop: if you want the thumbnail to be cropped (no image deformation) if the width and height are different from the original image, set this value as 1 or true. If you want the content of the thumbnail to be resized to fit the space (image deformation) set this to 0 or false (default=1).
halign: horizontal align of the croped image. You can set it to left, center or right (default=center)
valign: vertical align of the croped image. You can set it to top, center or bottom (default=center)
effect: you can apply two effects: grayscale and sephia
rotate: you can specify a rotation angle
background: hex color (like #ffffff) to apply on the background ONLY when you rotate the image. If you don’t want a color applied you can set this to transparent (default=transparent)
return: if set to 1 (or true) the image name will be returned instead of printed (default=0).

Examples

In this example I’ll not explain detailed how this WordPress code works, but I’ll show this as an example of this plugin usage:

<?php
$img="";
$args = array(
'post_parent'    => $post->ID,
'post_type'      => 'attachment',
'numberposts'    => 1,
'post_mime_type' => 'image'
);
$attachs = get_posts($args);
if ($attachs) {
$img=wp_get_attachment_image_src($attachs[0]->ID,'full');
}
if(!empty($img)){
?>
<img
src='<?php thumbGen($img[0],171,56,"effect=grayscale&halign=left&valign=top"); ?>'
alt='' />
<?php
}
?>

This example reads the first attached image of a post and save it’s information in a variable called $img. In the thumbGen function the first parameter is $img[0] and that’s the image URL. The second and third parameters are the width and height of the generated thumbnail we need. The rest of the parameters are defined in the string in the format parameter=value, concatenated with an &. the values not specified will use their default value.

To do

  • Recieve a lot of donations!: I have faith in you!
  • And, of course, if you have any idea on how to improve this plugin, please let me know

I hope you enjoy this plugin… and please let me know any bug you find!!! … thanks ;)

86 Comments Comments Feed

  1. Kenneth (23/02/2010, 18:00). Reply

    Does it support external images, outside my domain?

    • Sebastian Barria (11/02/2011, 02:23). Reply

      UPDATE: Yes, it does!

  2. admin (23/02/2010, 22:47). Reply

    No, I’m sorry, because it uses a PHP function to open the image, and because of that, it needs the original image to be in yout domain (otherwise it couldn’t open it). But you could save the image on your domain, I guess?

  3. Cristian (24/02/2010, 12:17). Reply

    I Love this plugin :)

  4. Victor (26/02/2010, 16:52). Reply

    how is it diferent than the new post thumbnail feature?

    http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/

  5. admin (01/03/2010, 00:35). Reply

    In response to Victor: a lot!….if you want to make a Gallery, you can’t use the post thumbnail feature. You can use this function in any image of your site…you can use it for banners, icons, etc.. and you don’t have to declare it on the file functions.php….it’s already declared. You can generate the image in b/w to make rollovers, but you can’t do it with the post thumbnail feature. I hope you enjoy it.

  6. Li-An (03/03/2010, 12:01). Reply

    It would be perfect if it could use custom fields too (to put a default image or changing a thumbnail).

    • admin (03/03/2010, 12:09). Reply

      Hi Li-An…could you explain more about your ideas?…it could be interesting….thanks ;)

      • Samuel (05/03/2010, 14:19). Reply

        I think that Li-An idea is about adding a custom field in the post containing the thumbnail URL when the thumbnail is created.

        This way, you can easily edit the thumbnail URL and change it for any other.

        And if the plugin checks for the custom field before start the thumbnail generation, you can add your own default thumb or whatever… :)

        I would like to see that feature too (in fact, maybe I’ll add this for my own use).

        • admin (05/03/2010, 15:39). Reply

          Mmmm…I think that your idea is the same that victor asked before, about the “new post thumbnail feature”… you could do it with that feature, but the idea of this plugin is to go beyond… to be able to generate any picture on your template, not just the post ones :)

  7. ThumbGen – Plugin, чтобы производить миниатюры | Pomoshh' WordPress (11/03/2010, 02:05). Reply

    [...] Себастьян Барриа, который освободил новый plugin: ThumbGen. То, что предлагает этот предмет кода, состоит в том, [...]

  8. ThumbGen – Plugin to generate miniatures | Help WordPress (11/03/2010, 02:06). Reply

    [...] have just be warned by Sebastián Barría who has liberated a new plugin: ThumbGen. What offers this code piece is to autogenerate miniatures from any image loaded in your [...]

  9. Li-An (13/03/2010, 18:37). Reply

    Sorry I did not answer before… Yes, Samuel was right with my question. I use already a plugin to generate different sizes of thumbnails for my blog. As the plugin seems to be abandoned, I’m searching for other solutions in the future. The plugin I use has the ability to check a custom field to see if there is an image defined before creation a thumbnail from the image attached to the post. It gives the opportunity to change easily a thumbnail (sometimes the cropping/resizing gives a bad thumbnail and it’s good to “force” with another image).

  10. ThumbGen: un plugin para generar thumbnails | TodoWordPress (14/03/2010, 15:04). Reply

    [...] Más información en la página oficial de thumbGen. Etiquetas: Imágenes, Plugins, thumbGen, WordPress [...]

  11. Cristian (16/03/2010, 13:43). Reply

    Estimado, te quiero felicitar por el excelente trabajo, este plugin ha sido el único que ha cumplido todas mis expectativas y el manejo de el es impresionante. Un abrazo gracias por compartir tu trabajo.

    • Sebastian Barria (21/04/2010, 14:37). Reply

      Muchas gracias Cristian. Espero poder ir mejorándolo con el tiempo. Gracias por tus felicitaciones :)

  12. gambuto (21/04/2010, 13:22). Reply

    But does it work that

    you can set a img size for the img in a post and for your homepage? So that you wil have a thumbnail on your homepage and an extended img inside the post

    • Sebastian Barria (21/04/2010, 14:36). Reply

      Of course!… that’s the idea of this plugin. You can have as many different image size you want from the same picture. One on the home page and one inside the post.
      Good luck!

  13. ronnie (25/04/2010, 10:02). Reply

    hi sebastián,

    thanks for the very useful plugin!
    one serious bug which you can easily fix:
    i tried to implement the plugin but received THE SAME PIC for every post! the reason is that i use the same picture name everywhere but in a different folder for each post.

    the plugin writes and reads the picture from the cache directory and disregards the case for images WITH THE SAME NAME.

    my solution was to insert into the $ruta var the additional folder info i needed. changed from:
    $ruta=”wp-content/uploads/cache/”;
    to:
    $ruta=”wp-content/uploads/cache/”.get_the_excerpt().”/”;

    thanks again!
    ronnie :)

  14. Dave (13/05/2010, 09:02). Reply

    Hi,

    Firstly, this plugin is great!

    However, I am trying to use it with custom queries, as I want to apply the function to images added via a custom field but when the URL gets parsed through thumbGen, i just get a white image whereas before, when i was using it on attachments, they were fine. Both the URLs for the images are the same and live in the same directory on the same domain.

    Any help would be hugely appreciated!

    Cheers

  15. Dave (13/05/2010, 12:44). Reply

    Actually, ignore my last comment. I have worked it out by doing a regex on the src attribute of the img element and then using that to get the original filename and running that through thumbGen. :)

    Even happier now

  16. ThumbGen: un plugin para generar thumbnails (22/06/2010, 19:50). Reply

    [...] Más información en la página oficial de thumbGen. Imágenes, Plugins, thumbGen, WordPress [...]

  17. Alonso (25/06/2010, 22:27). Reply

    Estimado,
    Primero que todo quiero agradecer con gran efusividad este plugin debido a que me ha ayudado mucho en los sitios que he creado apoyado por wordpress y ha funcionado a la perfección,
    Lamentablemente me ocurrió un problema en un único sitio, puedo instalar el plugin sin problemas, coloco el llamado a la función del plugin en mi template, pero no me aparece la redimensión de la foto, no aparece nada, estuve revisandolo con el inspector de firefox y me sale el siguiente error,
    Warning imagesx(): supplied argument is not a valid Image resource in…
    revisé la carpeta de uploads y cache y en esta última me crea una imagen en blanco del tamaño que le pido pero no me crea la imagen correspondiente,
    Que puede ser?
    De ante mano muchas gracias

    • Alonso (26/06/2010, 20:16). Reply

      Estimado, es sólo con el wordpress 3.0 que tengo problemas, las versiones en las versiones anteriores de wordpress funciona bien.
      Saludos y espero tu ayuda,
      Que estes bien.

  18. Daniel (29/07/2010, 08:27). Reply

    Tried it. Followed your instructions. Got an error (warning.. the plugin file, lines 36/37) WP 3.01.

    Oh well.. back to hacking TimThumb!

  19. Pablo (20/09/2010, 16:53). Reply

    Muchísimas gracias, Seba!! Excelente trabajo! Gracias!

  20. fast learning (05/10/2010, 18:22). Reply

    amazing plugin! exactly what i was looking for!

  21. Miklas Njor (06/11/2010, 12:30). Reply

    Hi Sebastián.

    I’m trying out different plugins to play around with thumbnails and yours *reads* by far to be the best. But I can’t get it to work straight off the bat.

    They php arg-code you show above, is it to be copypasted as is, or do I need to modify it?

    I’m working in an test enviroment via MAMP.

    Kind regards, Miklas.

    • Sebastian Barria (07/11/2010, 20:19). Reply

      Hi Miklas.
      Yes, it should be copy/paste.
      The only thing you need to check are this 3:

      1. To retrieve/use the correct image URL (you must be sure the image is accessible)
      2. That your server have installed the GD modlule
      3. That you have correctly configured the plugin

      Good luck!

  22. Angel (07/11/2010, 16:51). Reply

    Ayuda con WordPress, estoy utilizando WAMP server local en mi pc con WordPress 3.0.1.
    El theme que estoy usando es Wordtube con varios videos locales en mi pc.
    Este funciona bien pero no tengo una imagen en el thumnail de las paginas.
    Dejame saber si tu plugin me funciona si la respuesta es si, dejame saber como instalarlo correctamente.
    Gracias por tu ayuda….Angel

    • Sebastian Barria (07/11/2010, 20:22). Reply

      Hola Angel.
      La respuesta es la misma que la anterior (pero esta vez en español):
      Debes asegurarte de estas 3 cosas:

      1. Obtener y usar la URL correcta de la imagen (debes asegurarte de que la foto sea accesible)
      2. Que tu servidor tenga instalado el modulo de PHP llamado “GD”
      3. Que hayas configurado correctamente el plugin

      Asegúrate de que no tienes problemas con estos tres puntos y todo debería funcionar bien.
      Buena suerte!

  23. Angel (09/11/2010, 19:57). Reply

    Gracias por tu respuesta, no me ayuda mucho soy bien rookie en el uso de la aplicacion.

  24. Jano (16/11/2010, 08:21). Reply

    Saludos Sebastian.

    Fantastico plugin. Hace lo que se espera que haga perfectamente.

    Hasta ayer. Extrañamente, trabajando en local con un diseño, desde ayer recibo un mensaje de error HTTP por parte de servidor Apache local.
    Estoy con varios diseños a la vez y primero sucedió en uno y no en los otros. Pero después empezó a suceder en otro y ahora sucede en todos. El problema está en mi servidor ya que lo que tengo puesto en Internet funciona perfectamente.

    ¿Alguna sugerencia?

    En cualquier caso, enhorabuena y gracias por tu trabajo,

    • Sebastian Barria (16/11/2010, 09:51). Reply

      Gracias Jano!.
      Claro, lo que puedes revisar es la versión de PHP (que sea lo más actualizada posible), que tengas activada la librería GD y que las imágenes que estés convirtiendo no superen en peso a la memoria que tiene habilitada PHP, que esté bien configurado el plugin (que la carpeta exista y tenga permisos), y que estés llamando a la URL correcta de la foto.

      Suerte!

  25. JessicaX (07/12/2010, 14:05). Reply

    Love the plugin, I wish I could use it!!

    Seems I cant get the plugin to find/accept the cache-folder.

    Under settings I get this Error:
    The specified folder doesn’t exists and I was not able to create it :(

    I do have that folder, and it’s rights are set to chmod 666

    What can I do? Thx!

    • Sebastian Barria (07/12/2010, 15:23). Reply

      Hi Jessicax.
      Try chmoding it to 777 and be sure the URL you’re using exists.
      If you want you could give me more info… wich version of wordpress, what’s the path you’re using?

  26. JessicaX (08/12/2010, 10:18). Reply

    Hello :)

    iv’e tried chmod 777 as well, but same strange result :(
    And the paths i’ve tried are wp-content/thumbgen_cache
    AND wp-content/uploads/thumbgen_cache

    The plugin never finds it.

    im using WordPress 3.0.2

    • Sebastian Barria (08/12/2010, 13:30). Reply

      have you tried starting with a “/” (/wp-content…) ??

      • JessicaX (09/12/2010, 10:33). Reply

        Yes! I got it solved thanks to Miklas entry. I have wordpress in a subfolder too, and adding that to the path solved it. TY!

  27. Miklas Njor (08/12/2010, 13:39). Reply

    Hi Sebastian.

    I got it to work as soon as I found out how simple it is! It’s fantastic. Solves so many problems and now wordpress has a feature like drupals imagecache. Brilliant.

    It works fine on MAMP and wordpress 3.01. I just had to figure out that if you have a site in a subfolder the path is /SUBFOLDER/wp-content/thumbgen_cache otherwise it creates a folder in the root’s wp-content.

    But at new problem arose when I exported it to a live site. It just shows black boxes in the sizes I choose.

    GD library is installed.

    Folder is writable (tried 775, 776 and 777)

    I’ve checked MySQL for possible loose ends when exporting. Couldn’t find any and other images are showing.

    I’ve created the folder (it didn’t do it automaticly) but it doesn’t put any images in it.

    I’ve tried to flush the cache but still no help

    My solution was to just copy the folder to the server, but I’d like to get it working probably.

    Any suggestions?

    ———
    Server info:
    OS: Linux
    Server: Apache
    Hostname: miklasnjor.com
    Document Root: /I/better/hide/this/info/public_html
    PHP

    v5.2.14
    GD: bundled (2.0.34 compatible)
    Magic Quotes GPC: On
    Memory Limit: 256.0 MiB
    Max Upload Size: 15.0 MiB
    MYSQL

    v5.1.47-community-log
    Maximum No. Connections: 1,500
    Maximum Packet Size: 256.0 MiB
    Data Disk Usage: 1.6 MiB
    Index Disk Usage: 456.0 KiB
    ———————

  28. Hugo (09/12/2010, 12:26). Reply

    Hola Sebastian, una duda ¿solo sirve para el front end? ¿no hay uno para el back end?, yo quiero que las imagenes no esten dentro del contenido de una entrada, sino que se guarde en un campo aparte. ¿hay algún plugin al respecto?

  29. kcmr (08/01/2011, 08:39). Reply

    Hola. Veo que se excluye la imagen destacada, que es justamente la que quiero mostrar. ¿Cómo puedo hacerlo?

    Gracias!

  30. kcmr (08/01/2011, 09:26). Reply

    Hola de nuevo. Ya tengo la solución. Dejo un link para quien le pueda ser útil: http://alidark.com/wphack/post-thumbnail-get-url-link/


    Ruta a la imagen:

    Saludos y mil gracias por tu plugin.

  31. B-W-Design (13/01/2011, 02:48). Reply

    Hello Sebastian,

    i got a very strange problem. It generates only black thumbs. Or if i set it to sephia they get brown. i mean a full black square or a full brown square. What could this be?

  32. Miklas Njor (13/01/2011, 06:44). Reply

    Hi B-W-Design

    I have the same problem. It’s strange. On my MAMP local install it will get images from a blog in a subfolder, but on my site it won’t get them at all.

    My solution is to upload the images in the thumbGen cache folder from the working local solution to the online site’s thumbGen cache folder and hey-presto the images are shown.

    Is your site in a subfolder? Then you need to change the path to the ThumbGen cache in the plugin setup to include your subfolder:

    Example:

    Change: /wp-content/thumbGen_cache
    To: /SUBFOLDERBLOG/wp-content/thumbGen_cache

    Miklas.

  33. B-W-Design (13/01/2011, 07:08). Reply

    Hi Miklas,

    right now i am waiting for reply of the support from my hoster. It seems to be a server-problem.
    if i have mor infos i’ll post it.

    Janne

    • Pascal (28/01/2011, 07:35). Reply

      could you find out why pictures became black? I also have this problem. Tried out on several Servers, allways the same problem :-(

      • Sebastian Barria (28/01/2011, 08:06). Reply

        Hi Pascal. Probably it happens because the plugin can’t open the original image. If you don’t define the default image the thumb will be black. Otherwise the thumb will be the default image.
        Try printing the original image url you’re sending to the plugin and check if that’s readable.

        • kcmr (01/02/2011, 22:21). Reply

          Hi, I have the same problem and when I remove the @ from thumbgen.php in line 174 ($im = @imagecreatefromjpeg($file);) I get the following message:

          Warning
          URL file-access is disabled in the server configuration [...]
          failed to open stream: no suitable wrapper could be found [...]

          Is this a server configuration problem, like it seems to be?

          Thanks

  34. cmacias (16/01/2011, 08:49). Reply

    Hola Sebastian, enhorabuena por el plugin. Es fabuloso :-)

    Aunque tengo un pequeño problema con él. En una instalación local, funciona de maravillas. En el servidor de desarrollo me salen las miniaturas de color negro.

    El propio plugin me escribe la carpeta y le asigna los permisos necesarios. A pesar de que se los cambio manualmente, sigue en sus trece de mostrarme esas cajas negras.

    En el servidor tengo instaladas las GD 2.0.34 que es la misma que tengo en local.

    Alguna pista ?

    Un saludo y gracias,
    Carlos.

    • Sebastian Barria (16/01/2011, 17:23). Reply

      Hola cmacia.
      Si se ve la imagen negra es probablemente porque no es posible leer la imagen original. Talvez por un problema de rutas (aveces pasa esto cuando el sitio está instalado en un subdirectorio) asique lo primero que tieenes que hacer es ver si la imagen que le envias al plugin es visi le via URL.
      Suerte!

  35. jane (21/01/2011, 06:05). Reply

    I tried leaving the path to the cache folder at default – /wp-content/thumbgen_cache/ and it gave me the error as mentioned above “You haven’t specified the cache folder. If this is not configured properly, thumbGen will not work!” I am still developing the site and the current ulr is http://www.theanglemedia.com/~wsports3/, yes I’ve tried using /~wsports3/wp-content/thumbgen_cache/ but no success. Please help.

    Thanks!
    Jane

  36. Jon (11/02/2011, 00:42). Reply

    I love this plugin! Thanks for creating it. Can you tell me what the license is for this? Is it MIT?

    • Sebastian Barria (11/02/2011, 02:15). Reply

      Well… mmm… I didn’t think about that…
      But now that you asked, I’ve putted a CC licence for this plugin. Thanks for opening my mind!

      • Jon (17/02/2011, 18:50). Reply

        Thanks Sebastian!

  37. Joseph Ting (28/03/2011, 23:44). Reply

    Hi,

    Looks like thumbGen doesn’t support PNG?
    Browser return with Error 101 when there is PNG being passed into thumbGen.

    Is there no other choice but to convert the image to JPEG?

    Anyway, this is a great plugin!
    Thanks a lot.

    - Joseph

    • Sebastian Barria (29/03/2011, 11:50). Reply

      Hi Joseph.
      Yes, it support PNG. I’ve never heard about the error 101. I’ve googled and it looks like it’s a problem on google chrome.
      Please check that out. I’ve used thumbGen in many sites and it never happened to me.
      (And if you find the solution, please post it here for others to know)
      thanks!

      • Joseph Ting (01/04/2011, 02:37). Reply

        I see. I don’t know about it. I just converted png to jpg as there’s only some images are uploaded in png.

        One more thing though. How do I specify default image? Or when there’s no image, create a transparent image instead of black image?

        • Sebastian Barria (01/04/2011, 08:00). Reply

          You should do that in the settings / thumbgen page in the wp-admin. You could specify a transparent png or a white jpg as the default image.
          Good luck

          • Joseph Ting (06/04/2011, 04:51).

            Yes. Did that. However, transparent will not work as the generated thumbnail will be in .jpg. So, I’ll just use white background.

            Let me get you a cup of coffee man! =)

          • Sebastian Barria (06/04/2011, 10:17).

            Thanks a lot man! (recieved)
            I hope my plugin works fine for you. Any suggestion will allways be well recieved.

  38. Alonso (07/04/2011, 11:36). Reply

    Estimado, primero que todo agradecer por el plugin y que sea un compatriota el que lo desarrolló :) , tengo una consulta, cómo puedo especificar la calidad de la imágen? se puede realizar como lo hace timthumb?
    Gracias!

    • Sebastian Barria (07/04/2011, 12:28). Reply

      Mmmm… excelente preguta tutu-tutu…
      En este minuto la calidad está fija (90 para JPG y 7 para PNG), pero podría implementarlo fácilmente en una nueva versión del plugin…. lo tendré en cuenta.

      • Alonso (07/04/2011, 14:58). Reply

        Muchas gracias por tomar en cuenta la opinión de los usuarios, un saludo y que tengas buen día

  39. Jon (12/05/2011, 18:08). Reply

    Is it possible to echo the dimension value when it’s set to zero? Such as: <img src="" alt="" width="596" height=""/>

  40. Jon (12/05/2011, 18:10). Reply

    Sorry, the code above didn’t show correctly, this should show it: <img src="” alt=”" width=”596″ height=”"/>

  41. Jon (12/05/2011, 18:11). Reply

    doh! still not showing: <img src="” alt=”" width=”596″ height=”"/>

    • Sebastian Barria (12/05/2011, 19:09). Reply

      Hi Jon.
      Yes, it could… but it would change the way to use the plugin and it would be terrorific!. To do that it should return an array with data (image,width,size) instead of a string… so it would be complicated.
      Anyway… why would you need the widh and size?… when you use the thumbgen, you set the image width and size, so it wouldn’t be necesary.
      The only solution I figured out is that the returned string have at the end a “?width=500%height=200″, so that way it won’t produce any troubles. But that way you will need to use the thumbgen with the “return=true” option and then explode the string to get the data.
      Anyway… what image size would you need?… the generated or the orignal?… this will be probably my next upgrade :)

      • Jon (12/05/2011, 20:21). Reply

        Hi Sebastian, Yes I’m trying to get the generated image size.

        So when I put the values in at something like ($src,596,0,…) i want to be able to know what the generated “0″ (height) becomes and echo that in the img tag height=” ” so that I can dynamically define the img tag height, since my images all vary in size. This also would help so I could use that output size in another part of the page too.

  42. Joseph Ting (18/05/2011, 04:50). Reply

    I got a weird and big problem.

    ThumbGen was working properly until I switched to Ubuntu (from Windows 7). I’m talking about developing machine though.

    ThumbGen just doesn’t work unless there’s cache.
    All cached thumbnails are working, if being forced to generate the thumbnail or there’s no cache, the page breaks.

    Whole page breaks until the first thumbGen() with no cache.

    Any idea why is this happening? I figured that it was because my PHP doesn’t have GD. But I’ve installed it yet it’s not working. CHMOD-ed /wp-content/images/ to 777 and plugin page says it will work properly after I save the changes.

    And here is the screenshot of my phpinfo where GD is loaded. I’m out of idea what’s going wrong already. =\

    • Sebastian Barria (18/05/2011, 09:38). Reply

      Hi Joseph.
      The plugin gets the images from the wp-content/uploads (or images) folder. Then it creates the thumb and save it on the wp-content/thumbgen_cache folder for future use. You must be sure this cache folder is writable and readable (777)

      • Joseph Ting (18/05/2011, 21:22). Reply

        My cache folder is “/wp-content/images/” and I’ve already chmod this folder to 777. It still doesn’t work.

        Now my page load until the first thumbGen() and it breaks there.

        • Sebastian Barria (18/05/2011, 21:54). Reply

          Oh! You should have said that before. That’s a known issue (known by me of course). Your problem is that the image thumbgen is trying to open is too big. It is probably 3 or 5 megapixels. Depending on the server you’re working on thumbgen will be able to manage different image sizes. It depends of the server’s available memory. The best you could do is to replace that image for a small one. You could even install a plugin like “resize at upload plus” to avoid future problem (it will resize images you upload).
          This problem is easy to identify if you look at the page’s generated source code: if you look at the end of it you’ll find a tag like Good luck!

          • Joseph Ting (18/05/2011, 22:24).

            I hope that is the problem, man. But looks like it’s not.
            The image that needs to be resized is just 58.3KB (600x402px) big image.
            My PHP memory_limit is 128M and that should definitely be able to do this task no problem right? I have no idea what’s wrong.
            I even written a simple php script to check whether the folder is writable with is_writable(). And a php script to create a file there. They seems to have no problem at all.

          • Joseph Ting (19/05/2011, 02:06).

            It seems like it’s working now after my “determination”. LoL~
            I have GD installed but not libjpeg. Duh!!
            This is my first time developing on Ubuntu anyway. =D
            Thanks for your help so far, Sebastian. =)

  43. cvaz (24/05/2011, 01:05). Reply

    It’s Amazing!!!… Love it!!!!!!
    tanks…. this plugin is spectacular…

  44. Martin (24/05/2011, 06:49). Reply

    Hi Sebastian,

    ThumbGen in exactly what I’m looking for to give me greyscale thumbnails for my previous and next post buttons — unfortunately my PHP is not very good and try as I might I cannot make it work with the code.

    The code is simple (it puts the post thumbs in the sidebar, with a custom thumb size created using the Simple Image Size plugin):

    ID, array(105,57) ); echo $prevthumbnail; ?>

    (and then the equivalent for the ‘next’ thumb)

    I’ve tried many different ways and I’ve had various errors and such and just can’t get it working. I tried it with an absolute url and it successfully produced the thumb, so I know the plugin is working.

    Can you help?

    Cheers,

    Martin

  45. Garv (08/07/2011, 05:07). Reply

    Hello.

    I’m trying to get thumbGen to work and I think I might be missing something fundamental and that may be causing all of my problems. Basically, I just want to manually add thumbnails to my posts without the need for running some kind of crazy script. I also want to grab pics from my own location.

    Basically what I have is this:

    < img src='’ / >

    For some reason this simply doesn’t work. It is possible that I am misunderstanding the purpose of this script, but I figured I’d check here first before I gave it all up.

  46. Garv (08/07/2011, 05:10). Reply

    Ugh…that didn’t work out right… how about this:

    [ img src='[?php thumbGen("http://someimage",75); ?]‘ /]

    The should be there, but they’ve been replaced by [ ] so that the code shows up.

  47. Goran (01/11/2011, 14:46). Reply

    Thank you for great plugin. I am using it with my site as thumb.php had high proccess usage and site got suspended coz of that. My fix was to use yours plugin in template instead of thumb.php. Its working great but the only thing i found out is that it doesnt work if i use set featured image from media library, its working fine if i use upload. I am not programmer, but i have been reading wordpress codex and cant find the fix. Maybe you can help me with this;

    I`ve used this code from your example

    $post->ID,
    ‘post_type’ => ‘attachment’,
    ‘numberposts’ => 1,
    ‘post_mime_type’ => ‘image’
    );
    $attachs = get_posts($args);
    if ($attachs) {
    $img=wp_get_attachment_image_src($attachs[0]->ID,’full’);
    }
    if(!empty($img)){
    ?>

    its ok if i upload new picture, but its not working if i chose picture from media library. Can u help me on this ?

    • Sebastian Barria (02/11/2011, 18:42). Reply

      Sorry about the late answer, but I got into your site and everuthing seems to work fine… isn´t it?
      Good luck!

      • Goran (03/11/2011, 07:27). Reply

        Thanks for the answer. Yes, everything works well if i upload image while writing new post, but if i want to chose image from media library instead of uploading it, then nothing shows up.
        You can see it here on my test page that thumbs are not showing even if i have chosen preview image in post.

        http://atvbl.com/vijesti/

        again many thanks for help.

  48. Mike (30/11/2011, 11:32). Reply

    I’ve used your plugin before and it worked great. I’m trying it on a new server and all of my thumbnails are showing up as black squares. Any ideas?

    • Sebastian Barria (30/11/2011, 12:24). Reply

      Hi Mike.
      That could be happening because of two reasons:

      • The plugin is not well configured in the new site
      • The site you’re working on is password protected

      Check if the site is on a sub-folder. Print on the page the URL of the original image you’re trying to get; copy the URL and paste it into a new page/tab. If you can’t see the image, that’s the reason.
      Good luck!

      • Mike (30/11/2011, 12:30). Reply

        Hey Sebastian,
        I checked both the original image and the generated one. The generated one is actually a black box. I tried creating an image in php and I get a file-access restricted error. Could this be the cause as its not allowing the file to open?

Add a Comment

Suscribirme a los siguientes comentarios vía email (también puedes suscribirte sin comentar.

Switch to our mobile site