Thumb-in-Post Version 0.91

This is an update to my WordPress plugin which simplifies insertion of thumbnails, pictures, Flash and Quicktime movies and Scalable Vector Graphics (SVG) into a blog post.

How it works

Thumb-in-Post adds three buttons to the Quicktags menu which will insert a a custom tag into the post. When the page is rendered it will use the information in the tag to generate all the code necessary to display the thumbnail, picture or object, and link to the full size image. Additionally, it will automatically generate thumbnails of JPEG and PNG files.

Installing Thumb-in-Post

The biggest problem that people seem to have been having with the plugin is installing it in such a way that it will actually be able to find your image folder. To try and fix that I’ve moved all the settings to a separate file (thumb-in-post.cfg) to make altering the paths a little simpler. This file should be placed in the WordPress plugin directory along with the actual plugin file. By default it’s set to look for images in the upload directory, but you can change that to whatever you want. A couple of other options that may work for you if the defaults don’t are included in the settings file but commented out.

Another advantage of having a separate configuration fileis that you won’t have to redo all the settings every time a minor bug fix comes along.

The images directory must have permissions set so that it is writable by the server.

As previously, you must have version 2.0 of the GD library installed on your server for automatic thumbnail generation to work.

How to use it

Using the plugin is simple. Once you have installed it three buttons will be added to the quicktags menu: Thumbnail, Picture and Object. Clicking ???thumbnail??? will prompt you for a filename and a caption, then insert a short custom tag into your post with the following format:

<--wp:thumb src="filename.jpg" cap="A caption" -->

When the post is displayed, this custom tag will be parsed into the HTML code necessary to display the image.

The picture button inserts a tag (wp:thumb) for display of an image at its full size, with no thumbnail generation. The object button inserts a tag (wp:object) for display of Flash, Quicktime and SVG and quicktime movies. They work in basically the same way as the wp:thumb tag. All the code produced is valid XHTML.

If you???re interested, download the plugin here. Don???t forget to to deactivate both the previous version of the Thumb-in-Post plugin and Image-in-Post plugin, if you have them installed. Any feedback would be appreciated.

Changes in version 0.9

Although the code is essentially all-new in this version, there are only two changes that will be noticeable in this new version.

Firstly, a number of new attributes can be added to the custom tags. Currently allowable tags are:

src
The filename. You really need this one.
cap
The caption text. If you want to use double quotes in the caption you’lll have to use escape codes.
alt
Alt text for the image/object. If left unset, the caption will be used. If there’s no caption it will apologize for your laziness.
class
If set this will cause a class attribute to be applied to the <div> surrounding the image.
id
If set this will cause an id attribute to be applied to the <div> surrounding the image. If unset an id will be set using the image filename less the file extension.
width
Sets the size of the image or object. This is only necessary if you want to use a picture at a size other than its current size or a thumbanil of a size other than the default in the settings file. Otherwise these attributes will be set automatically. To ensure that they display properly width and height attributes should be set for all Quicktime and SVG objects.
height
Works the same as width. NOte that if only the width or height attribute is set the image will be resized keeping the aspect ratio intact. This should answer the request to set a maximum height for generated thumbnails.

The second change is that I have included code which causes full size images of thumbnails to open in popup windows without all the browser chrome (i.e. menus, toolbars etc). See below for an example.

This option is turned off by default. It uses javascript to generate the popup windows and therefore will conflict with any other scripts or plugins that you have that use an onload event. Because of the many different things that might conflict with this I am not prepared to provide any support for this feature. If it works great, if not, don’t ask me what you need to do to fix it.

Edit: I’ve just fixed the popup window bug which causes all the javascript popup wndows to have the name ‘Ali Hassan’. In version 0.91 the blogname is used for the window title.

Javascript popup example

16 Comments »

  1. Pingback by WordPress Reference Centre » Thumb-in-Post version 0.9 [plugin] — August 26, 2004 @ 7:03 am

    […] in-Post version 0.9 [plugin]
    Filed under: Plugins — Shadow @ 8:02 am

    Thumb-in-Post version 0.9 – Thumb-in-Post adds three buttons to […]

  2. Comment by Brad Root — August 26, 2004 @ 7:37 am

    The pop up script is great, and I know you said no support for it, but I figured you’d like to know that all pop up windows end up titled “Ali Hassan”.

    Thanks for a great script. (Now if I could only get float:left; working without collapsing my divs. Damn CSS 😉

  3. Comment by Ali — August 26, 2004 @ 9:11 am

    Oh dear. I guess I’d better fix that. Version 0.91 in five minutes. It’s quite funny though.

  4. Comment by Ali — August 26, 2004 @ 9:27 am

    OK, it’s fixed now. The current version is 0.91

  5. Comment by PlanetPhillip — August 27, 2004 @ 6:38 am

    Hi,

    After installing the plugin with default settings and activating it, if I go to edit a post, I recieve this message:
    Parse error: parse error, unexpected ‘}’ in /home/myusername/public_html/wp-content/plugins/thumb-in-post9.php on line 22.

    Any Ideas?

    TIA
    Phillip

  6. Comment by Nicholas — August 27, 2004 @ 11:37 am

    I liked your plugin a lot before, but now that you’ve added the height attribute, I’m in love. Great job!

  7. Comment by Daniel — September 1, 2004 @ 7:34 pm

    I’m getting errors :S

    On top of every page I get:
    Warning: file(): URL file-access is disabled in the server configuration in -/wp-content/plugins/thumb-in-post9.php on line 15

    Warning: file(http://dansoft.clubhost.us/wp-content/plugins/thumb-in-post.cfg): failed to open stream: no suitable wrapper could be found in -/wp-content/plugins/thumb-in-post9.php on line 15

    Warning: Invalid argument supplied for foreach() in -/wp-content/plugins/thumb-in-post9.php

    Am I doing something wrong?

  8. Comment by Ali — September 1, 2004 @ 8:15 pm

    Dan,

    I think the problem is that your server is set up so that files cannot be requested by URL — that first error is probably the source of the others. You can fix this by altering php.ini but I doubt that your host is going to give you access to that.

    I think you can fix this error by doing the following.

    Open thumb-in-post9.php and change the line that reads:

    $lines = file(get_settings('siteurl')."/wp-content/plugins/thumb-in-post.cfg");

    to:

    $lines = file("./wp-content/plugins/thumb-in-post.cfg");

    (It’s right at the top).

    I think you will almost certainly have to change the setting ImageURL in thumb-in-post.cfg so that it is set as a relative path (e.g. ./wp-content or similar). This will prevent the same error from recurring later on in the code.

  9. Comment by Ali — September 1, 2004 @ 8:35 pm

    Actually, that change seems to work but you get errors in the admin screens.

    This might work better:

    $lines = file("/Complete/path/to/plugins/wp-content/plugins/thumb-in-post.cfg");

    Obviously, you’ll need to change that to make sense for your server.

  10. Comment by Daniel — September 2, 2004 @ 3:13 am

    That did the trick Ali, thanks!

  11. Comment by Chaplin — September 9, 2004 @ 10:59 pm

    Having some troubles with the pop-up. When using Firefox I can block out this line like so:

    // determine what the target window shouold be: _new opens in a new window. Set to target=”_self” to open in the same window
    // Set this to blank if you are using XHTML Strict.
    //Target == target=”_new”

    and enable pop-ups and it works fine. However, in IE then, the pop-ups don’t work and clicking on the thumbnail brings me to the image on a new page.

    If I make the line like so:
    // determine what the target window shouold be: _new opens in a new window. Set to target=”_self” to open in the same window
    // Set this to blank if you are using XHTML Strict.
    Target == target=”_new”

    and enable the pop-ups, it works great in IE, but puts the image on a new page and gives me a pop-up in Firefox. Any ideas?

  12. Comment by James — February 4, 2005 @ 3:45 am

    Hi Ali, I wonder if you’ve made it create a thumbnail everytime the pages is loaded…. or is it like.. it creates the thumbnail for once… and on every call it checks if the thumbnail is already available ( premade ) … just to reduce server load… Please let me know right on this comment board… I’m waiting for your reply I’ll download the plugin later…

    Anyway, truly you’ve done the best job… no one has made it this way.. you are the first one! Cheers!

  13. Comment by Ali — February 4, 2005 @ 8:14 am

    The latest version will use any existing thumbnail as long as it is the right size. So the thumbnail only gets made once.

  14. Comment by Henrikf — March 31, 2005 @ 5:26 am

    Hi!i have everything working in Firefox (but no thumb in IE6,just the link to fullsize image)

    but ! i get this error msg when i load the page with the thumb on ..

    My UL folder is in wp-inn in the root webfolder

    ————————————————–

    Warning: getimagesize(/wp-inn/aquarius.jpg): failed to open stream: No such file or directory in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 563

    Warning: Division by zero in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 582

    Warning: getimagesize(/wp-inn/thumb-aquarius.jpg): failed to open stream: No such file or directory in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 169

    Warning: imagecreatetruecolor(): Invalid image dimensions in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 531

    Warning: imagesx(): supplied argument is not a valid Image resource in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 534

    Warning: imagesy(): supplied argument is not a valid Image resource in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 534

    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 534

    Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 540

    Warning: getimagesize(/wp-inn/thumb-aquarius.jpg): failed to open stream: No such file or directory in /home/hosts/trollpack/www/trollpack.sverok.net/wp-content/plugins/thumb-in-post9.php on line 175

  15. Trackback by Related Site — January 3, 2016 @ 4:39 pm

    Related Site

    Ali Hassan » Blog Archive » Thumb-in-Post Version 0.91

  16. Trackback by www.jauntblog.com — December 9, 2016 @ 8:45 am

    http://www.jauntblog.com

    Ali Hassan » Blog Archive » Thumb-in-Post Version 0.91

Leave a comment

Comments are spam filtered. Your e-mail address will not be displayed. Some HTML tags are allowed.

(required)

(required, but not displayed)