Post Pic

Wordpress Plugin: The Attached Image

What’s This Then?
The Attached Image is a simple plugin that packs quite a punch. It shows the first image attached to the current post. For example. If you have your home page set to 5 posts and you use this plugin it will show the first image attached to each of those posts. For a [...]

What’s This Then?

The Attached Image is a simple plugin that packs quite a punch. It shows the first image attached to the current post. For example. If you have your home page set to 5 posts and you use this plugin it will show the first image attached to each of those posts. For a working example see celeborama.net which uses it to grab the picture you see floated to the left of each post.

It was inspired by a plugin wrote by Kaf Oseo, but when support & updates were no longer available & a recent upgrade of WordPress meant it didn’t work exactly like it used to, I decided to take on the challenge of remaking it using the newest WordPress functions available.

What’s It Do?

It has a lot of features, if you want to see them all then check the options list a litte further down the page. For now though here are some of the major ones that most people look for:

  • Can show the full, medium or thumbnail sized image attached to the current post.
  • Can make a hyperlink around the image that points to the post the image is attached to, the full image, the attachment page or a custom URL using custom fields on a post by post basis.
  • If more than one image is attached to a post then the image to be shown can be changed using the WordPress gallery page. Just pull the image you wish to show right to the top of the list and press save.
  • Can be returned instead of echoed so the output can be stored in a variable for developers to use as they wish.
  • Can show a default image if no image is available. Also changeable on a post by post basis via custom fields.
  • and more…

How Do I Install It?

It’s actually really simple to install. The hard bit is deciding where you want the image to go, but that’s entirely up to you. Here are the instructions you need to get it up and running:

  1. First go and get the plugin. Either from here or using WordPress’ new plugin installer (available since WP 2.7). Just search for the attached image or Paul Robinson.
  2. Unzip & place the folder into the wp-content/plugins folder. (I’m going to assume you’ve done this)
  3. Go to the plugins page of WP & activate the plugin. (Also assumed as done)
  4. Go into the template editor & find where you would like the image to show. It must be within the loop which looks something like this:
        <?php if (have_posts()) : ?>
    		<?php while (have_posts()) : the_post(); ?>
            	<!-- Some HTML will be here -->
            <?php endwhile; ?>
        <?php endif; ?>
      
  5. At the point you have found, place <?php the_attached_image(); ?>
  6. Go to the ‘The Attached Image’ options page under the WordPress Appearence menu.

So What About The Options

Functionality Options

This option allows you to switch on and off the perma functionality for in post image. This checks the post content for an image and grabs the image with the number you have asked for. If that number of image is not available it will show your specified default or return with nothing. Just press the checkbox & put in a number. It starts at 1 not 0 like some may think, so if you want to get the first image in the post press the checkbox & type 1 then save. This type of functionality can also be accessed on a post per post basis using the custom fields as explained later in this documentation. This has been extended with a new option to pick a thumbnails size to use. This will only work if the images were uploaded with WP, if they were not or they are linked in from a external source it will default to showing the full sized image.

General Options

Well The Attached Image now comes with a options page so you can alter what it does from the comfort of your WordPress dashboard. The Attached Image is all about adding a feature to your blogs design & because of that I have added it under the Appearance menu. Here is a description of all the options and what they do. First the general options:

Image Size
This is the size of image you would like to use. As of version 2.2 it supports WordPress’ generated thumbnails, medium size, large size images, and of course the original full size image. You can now specify a size using a function call to override the options page. This is great if you want to call the plugin twice on two template pages & want to use different size image. Use img_size= and then either full, large, medium or thumb. Use ampersands (&) to seperate parameters.
CSS Class
This is the class that you would like placed in the image tag. The default is attached-image and can be styled as normal through a CSS stylesheet. This option is so anyone who already has a class can use that if they wish. You can also call a different CSS class using function call parameters again options are seperated by ampersands (&). CSS class’ parameter is css_class Don’t use spaces in CSS class names when using this method. An example of both image size & css class together would be this. the_attached_image('img_size=thumb&css_class=custom-class');
Custom Image Size
Here you can input a custom image size. Beware, this uses the inbuilt width & height attributes of the image tag & as such can degrade picture quality if used too aggressively. Please use with caution.
Default Image Path
A simple one. This is the path to a default image if you wish to use one. Empty or leave the box empty to disable it. Very Important the image path must be from the WordPress root & not your hosts root, it must also start with a forward slash (/). So if your blog is in http://example.com/blog/ and you kept the image default.jpg in the wp-content folder the path would still just be /wp-content/default.jpg and NOT /blog/wp-content/default.jpg. It is also NOT the ID of another image.
Image Link Location
Do you want a link to be placed on the image that is produced & if so where do you want it to point. The possible options are no link, post, image & attachment page. I think it’s pretty self explanitory what they do. You can also provide a custom link on a post by post basis, more on that in the custom fields section further down the page.
Image Alternate Text:
Allows you to choose what the default alternate text for the image should be. You can choose either image filename, image description, post title or post slug. The description is taken from the description field that you can fill in when uploading an image via WordPress’ uploader. If one isn’t provided it falls back to the images filename. A custom value may be input via custom fields, see Custom Field Info below.
Link Title Text:
This is the text placed in the title attribute of the hyperlink placed around the image. This will only have an effect if you do NOT have Image Link Location set to No Link. The options are the same as the alternated text & a custom value can be input via custom fields, see Custom Field Info below.

Advanced Options

Now for the advanced options. Please be careful with these. Selecting the wrong option can result in the plugin not working correctly. I will at some point try to add a reset to default for instances where accidents have occured, until then though please be careful. Thanks.

Generate An Image Tag:
Fairly obvious… Whether to make an image tag or just place the full URL to the selected size image onto the page. If a link location is selected then it will also create the selected hyperlink around the URL. This can be useful to some people so feel free to be inventive.
Echo or Return:
Also fairly obvious, if you are a coder. Tells the plugin whether to echo out the output or return the output ready for processing by PHP. Can also be used to do some inventive stuff with the output.
Hyperlink Rel Attribute:
This should allow the plugin to work with most, if not all lightbox scripts. Refer to the documention of the lightbox script for what to place in the rel attribute.
Image Order:
By default the plugin will use the image in the first position of the WordPress gallery page. The image to show can be changed by reordering the images on the WP gallery screen, however you can use this to change which image it will pick. If you change this to 3 it will always try to pick the 3rd image in the WP gallery order. If there isn’t 3 images it will pick the nearest it can get to the 3rd image.

What About Those Fancy Custom Fields?

Some of the options can be changed on a post by post basis through the use of custom fields. These are the available keys, what they do & the values they expect. All of the keys prepended with att so that they are easily recogniseable as for use with The Attached Image & to stop conflicts with other plugins that may use custom fields.

Key: att_custom_img
This field is used to show any image from the WordPress attachment database, even if it isn’t attached to the current post. It requires the ID of the image you wish to show. It can generally be found out in the media section of WordPress.
Key: att_default_pic
Allows you to override the default picture that is to be shown if no picture is available. Path rules are exactly the same as the previously mentioned option.
Key: att_width & att_height
Pretty obvious, but it allows you to change the width & height of the image. It again uses the in-built browser method of resizing, so again be careful. Also please remember these are two seperate keys, I have listed them together but you must use two custom fields one for width & one for height.
Key: att_custom_link
Allows you to chose a custom URL for the hyperlink to go to. It will override the setting chosen in the options page for that single post. If you have selected no link in the options using this will override it and create a hyperlink for that single post.
Key: att_custom_alt
Allows you to chose a custom alt attibute to be placed in the image tag.
Key: att_custom_link_title
Allows you to chose a custom title attribute to be placed in the hyperlink. Only has an effect if Link Image Location is NOT set to No Link.
Key: att_in_post_image
This feature was requested by Jake Garrison. It allows you to display an image that is inserted into the post & not attached via the WP uploader. It scans for img tags in the post and places it where ever you place the plugin call. Options are a number starting from 1 of the img tag you wish to pic from the post. 1 will pic the first, 2 will pic the second and so on. If there isn’t a img tag matches the number picked it will leave a blank space (return false). Example. If you choose 4 and there are only 3 images in the post in will return blank (return false).
Key: att_in_post_image_size
Allows you to choose the thumbnail size for the in post image function. This only works if the image was uploaded via WP. If it wasn’t or is linked from an external source it will default to the full sized image.

Custom Queries


The ability to easily use custom queries was added as of version 2.5. There is now a second parameter for the query object. All you need to do is hand the query object over to the plugin. Here is an example:

//Custom Query Example
$my_query = new WP_Query('showposts=2&cat=3');
while($my_query->have_posts()) : $my_query->the_post();
  //Other Post Details
  the_attached_image('img_size=thumb&css_class=image', $my_query);
endwhile;

It should be fairly easy to follow. All you need to do is look for the variable that WP_Query() is assigned to & hand it to the attached image.

Wait Up… I Have More Questions!

Really? You do! Well then your already in the right place. You can either leave a comment on this post, or if you prefer, you can send me an email using the contact page.

What If I Find Something I Want Added Or I Find A Bug?

Well you wouldn’t be the first. Most of the features now included with The Attached Image are there through requests made in the comments section, just scroll down & have a read. If you have found a bug or you want to request a feature then the process is the same as the last question. Leave a comment on this post or drop me an email via the contact page.

Alright… Say I’m Feeling Kind…

Ahhh. Say no more. If you are feeling generous then you can buy me a cup of coffee or two using the Paypal donate button just below.


If that’s not your sort of thing then you can always donate some money straight towards my hosting bill with Dreamhost using the button below. Dreamhost take payment via Paypal so you know it is safe & secure.

Donate towards my web hosting bill!

That It?

Yep. I’d just like to say a thank you to everyone who has downloaded, used, supported, commented on or even just looked at my plugin. It might be me who writes it, but without you guys out there to use and appreciate it there wouldn’t be a point. Thank you so much.

Also a little extra thank you to Alisher, Brian Wood, Steve, Jasper Visser, Jennifer the scriptygoddess, and RougeDeals. All these lovely people suggested a feature that got added to The Attached Image or have identified & helped fix a bug. Also a final thank you to everyone who has linked back to me and helped popularise The Attached Image.

Ya, Finished Now

Actually no, not quite.

Legacy Overrides

These are a list of legacy parameters that allow you to override the values set in the options page. This is useful if you want to have more than one call the the_attached_image() on different pages in you template, but you want them to show different size images, or remove the link and other things. Basically it allows you to call the plugin twice, but have it do two different things. The parameters are entered in Query String format an example is the_attached_image('img_size=medium&link=image&css_class=featured-image');.

img_size
Changes image size to be pulled back by WordPress. Options are thumb, medium, large & full. Default is thumb.
css_class
The CSS class to place inside the image tag.
img_tag
Whether or not to echo the URL in an image tag. Options are true or false. Default is true.
echo
whether to echo or return the output. True will echo, false will return. Default is true.
link
Where you want the link to go. Will only work if href is set to true. Options are none, post, image and attachment. It is also possible to use a custom URL via the custom fields, please refer to the custom fields section above for more. Default is post.
default
The path to a default image if one is wanted. The path must start with a forward slash and be based from the wordpress directory, not your hosts directory. Options are false & a path to the image. Default is false. Can also be adjusted via custom fields, again check above for more.
width & height
Two seperate parameters that do the obvious thing. The set a custom width & height for all images. This only resizes using the image tag width & height attribute, as such quality will suffer greatly when resizing too much either way. Also adjustable using custom fields, check above for more.
image_order
Allows you to change which image the plugin uses from the WP gallery page. Normally, if there is more than one image, the plugin will pick the image marked in 1st. This allows you to change that. If there isn’t a picture at the position then it will take the pictures as near to that number as possible. Default is 1
rel
The rel attribute is generally used to add lightbox scripts. Just put the word shown by your lightbox instructions here and all should work as long as href is set to true & link is set to image, since there has to be a link and the URL to the full image for the lightbox script to work.
alt
Allows you to choose what the default alternate text for the image should be. You can choose either image filename, image description, post title or post slug. The description is taken from the description field that you can fill in when uploading an image via WordPress’ uploader. If one isn’t provided it falls back to the images filename. A custom value may be input via custom fields, see Custom Field Info above.
title_link
This is the text placed in the title attribute of the hyperlink placed around the image. This will only have an effect if you do NOT have Image Link Location set to No Link. The options are the same as the alternated text & a custom value can be input via custom fields, see Custom Field Info above.

If You Are Still Using An Old Version Without The Options Page

You should really upgrade to the latest version so you can use the new options page, but if you are one of those people who just loves the old school (and why not) then here is a list of parameters. Custom fields are still exactly the same so please use the list above.

img_size
Changes image size to be pulled back by WordPress. Options are thumb, medium, large & full. Default is thumb.
css_class
The CSS class to place inside the image tag.
img_tag
Whether or not to echo the URL in an image tag. Options are true or false. Default is true.
echo
whether to echo or return the output. True will echo, false will return. Default is true.
href
If you plan to use the link feature (which will automatically generate an href around the image) then you must set this to true first. Options are true or false. Default is false.
link
Where you want the link to go. Will only work if href is set to true. Options are none, post, image and attachment. It is also possible to use a custom URL via the custom fields, please refer to the custom fields section above for more. Default is post.
default
The path to a default image if one is wanted. The path must start with a forward slash and be based from the wordpress directory, not your hosts directory. Options are false & a path to the image. Default is false. Can also be adjusted via custom fields, again check above for more.
width & height
Two seperate parameters that do the obvious thing. The set a custom width & height for all images. This only resizes using the image tag width & height attribute, as such quality will suffer greatly when resizing too much either way. Also adjustable using custom fields, check above for more.
image_order
Allows you to change which image the plugin uses from the WP gallery page. Normally, if there is more than one image, the plugin will pick the image marked in 1st. This allows you to change that. If there isn’t a picture at the position then it will take the pictures as near to that number as possible. Default is 1
rel
The rel attribute is generally used to add lightbox scripts. Just put the word shown by your lightbox instructions here and all should work as long as href is set to true & link is set to image, since there has to be a link and the URL to the full image for the lightbox script to work.
alt
Allows you to choose what the default alternate text for the image should be. You can choose either image filename, image description, post title or post slug. The description is taken from the description field that you can fill in when uploading an image via WordPress’ uploader. If one isn’t provided it falls back to the images filename. A custom value may be input via custom fields, see Custom Field Info above.
title_link
This is the text placed in the title attribute of the hyperlink placed around the image. This will only have an effect if you do NOT have Image Link Location set to No Link. The options are the same as the alternated text & a custom value can be input via custom fields, see Custom Field Info above.
in_post_image
This feature was requested by Jake Garrison. It allows you to display an image that is inserted into the post & not attached via the WP uploader. It scans for img tags in the post and places it where ever you place the plugin call. Options are a number starting from 1 of the img tag you wish to pic from the post. 1 will pic the first, 2 will pic the second and so on. If there isn’t a img tag matches the number picked it will leave a blank space (return false). Example. If you choose 4 and there are only 3 images in the post in will return blank (return false). Can also be set via the custom fields, without setting this parameter using the key above. Warning: This will override the normal function of this plugin if set as a parameter. If you use custom fields the plugin will work as normal except for the posts it is used on.
in_post_image_size
Allows you to pick a thumbnails size for the in post function. Will only work if the image was uploaded via WP. If it wasn’t or it is linked from an external source it will default to the full sized image.

That’s all the parameters, but seriously you should upgrade to the latest version. There is tentative support for the parameter based system, but it is only there as a backup until I can safely assume everyone is using the new options system. Please don’t hesitate to leave a comment if you have problems switching over to the new system, it is a lot better.

Now are you finished?

Yes, now I’m done.

Update: 14/12/2009

I’ve just created a PDF file to show everyone some of the advanced uses available when using The Attached Image. Hope it is of use. :) Advanced Uses For The Attached Image PDF

445 Responses

22.12.08 17:29:48

hi. Thanks for plugin

perfect.

Regards

22.12.08 17:48:23

Hi, I have one photo that starts my blog posts followed by its content.

After a couple of months, the pix are deleted by its original source, so my photos have the red “x” instead. Can your plugin help resolve this issue? Perhaps automatically replace “x” image by a photo that I upload to my server?

Worse case scenario, I could initially upload each photo into my server for each new post, but that would be too easy and also time-consuming.

Thanks in advance.

22.12.08 18:39:27

@Baron: No problem, glad it’s of use to you.

@Marc: I think I get what you want, but no this plugin won’t do that. This plugin pulls back the first image that is attached to a post in WordPress. If the image isn’t hosted on your server then this plugin won’t do anything.

You would need a plugin that checks to see if a query to the image src recieved a non 200 HTTP message and then replaced the src with an new default image. That could be extremely server intensive & I’m not even sure if it’s possible it looks like it is possible. This broken links remover plugin does something similar to what you want with broken href’s. I might see if I can knock something up a little later, but I was never very good at CURL & fsocketopen.

If that’s not what you meant then please drop me another comment & see if you can explain it a little more for me. I tend to go a little dumb around Christmas. Too much sherry. :)

27.12.08 23:22:23

This is what I was searching for!!! Thank you!
How can I set an image that I want for a post? Image that is not in the post but in the gallery (for example: in the thumbs folder). Thanks! Keep developing this plugin. It has the future :-)

27.12.08 23:30:23

@Alisher: Thank you for your kind words.

At the minute you can only get an image that is attached to the post, but you have given me an interesting idea for an extension to the plugin.

Just to confirm you want to beable to pic an image that has been uploaded and is in WP’s media database but is not actually attached to the current post? If so then it is possible, and I should beable to have that done in the next release. :)

Thanks again.

28.12.08 00:09:55

Yes, you got right! For example: a post has lots of pics. But I don’t want none of them, I want to set in the preview front page my own special picture that is in the WP Gallery or NextGEN Gallery.
The idea is: I want featured posts on the front page but all plugins (for featured posts) offer only title and excerpt in the preview without image.
Note: Plugin’s name THE ATTACHED IMAGE. May be you will omit the THE word. It’s better for searching and remembering.

28.12.08 00:18:41

Well normally Google just ignores ‘the’ so it probably wouldn’t make any difference, plus I can’t change the name on the WP respository. You are right though I probably shouldn’t have kept the ‘the’.

I think I can make it so you can select an any image that has been uploaded into WP though. I’ll probably do it tomorrow so keep a look out. :)

Edit: I’ve just made a little prototype change to the plugin and it seems to be working great. You can provide an ID for a specific image attachment via a custom field in a post or via the template call, just remember that if you call it via the template it will cancel out the plugins primary function & it will allways show the image from the ID you provided. You can also get the images medium or small thumbnails. It’ll probably be ready tomorrow.

28.12.08 16:01:51

Hi,

Thanks for the cool plugin

How to you get the image to link to the post?

28.12.08 16:12:03

That would be like this:

the_attached_image('href=true&link=post');
29.12.08 02:48:21

Hey there… this seems great. One question: how can I (or can I) make it show the full size of the image, instead of a thumbnail or scaled down version? I’m trying to use this to fill a design need and I want the displayed images to be exactly what is attached.

Again, good work!

29.12.08 02:59:05

Wow, the features are coming thick and fast.

While it seems sensible to be able to do that I just hadn’t thought about it. I’ll add that later on today for you. Well after I’ve gotten some sleep. :P

Oh and thanks for the complements. It’s always nice to know the plugin is actually of use to people.

29.12.08 03:22:48

I solved my own problem. Your code was well commented! I’d suggest implementing this officially in a future release, but what I basically did was find where you are pulling the $img_size and modifying the $img_url to grab the smaller versions (line 96-116). Then I very simply added a “elseif ($img_size == ‘full’) { } before the thum default. So now if I put in an $img_size of full, it just pulls the original image. Easy-peasy.

Anyway, thanks again, you saved me hours of work building this from scratch!

29.12.08 03:23:29

And yeah, get some sleep! Happy New Year!

29.12.08 10:23:51

Hi Veneficus Unus (plugin’s author), THANK U sooo much that added the CUSTOM IMAGE field. I will explain how to use it:

In the template, where the post loop is, add <?php the_attached_image(); ?>. See example below:

<div id="contentwrapper">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<div class="topPost">
<php the_attached_image(); ?>

<h2 class="topTitle"><a href="" rel="nofollow"><?php the_title(); ?></a></div>
<div class="topContent"><?php the_content('(continue reading...)'); ?></div>
<div class="cleared"></div>
</div>
<?php endif; ?>
</div>

Then open your post in the admin panel. In the CUSTOM FIELD under “key” add “att_custom_img” and under “value” add “ID of picture” (ID of picture is number, you can find it under the MEDIA LIBRARY menu, place your mouse over the picture title and you see ‘…attachment_ID=14′).

Actually, based on this plugin you could develop another one, say “The Featured Posts”. Just add Title and Excerpt.
Thank you, Great Little Plugin.
Funny New Year!

Edited by Veneficus Unus: Sorted out the HTML etc. WP tends to be a pain when writing HTML in comments. Nearly right too, but you don’t need to put the_attached_image('custom_img=att_custom_img');, you can put the ID in either the template call so like this the_attached_image('custom_img=12'); or in the custom field like you have said.

29.12.08 15:37:18

@Brian: I’ve now added that feature to the code & should be available via update or from the WP repository.

Even though you have added it in yourself you’ll need to update since I started with your fix & although it works the actual img tag never gets closed since there is no width & height. I have sorted that out so it will work correctly & be valid HTML. :) I hope that makes sense.

@Alisher: Thanks for the little tutorial there. :) I deleted your second post since WP stripped it again & I cleaned up your code in the previous one and added a little comment. :D

30.12.08 03:09:54

@Vene: Awesome. All that is good and right with Open Source software right here! For what it’s worth, what I’m doing is using your call to generate a style=”background-image:url()” for a div, then putting a design element (a wedge graphic) over top of it. The “foreground” elements stay the same, while the bg images change depending on the post selected.

I’ve done it before with Flash but using your plugin, I can do it with just PHP. It’s a really nice effect and wouldn’t be nearly as easy without your plugin.

Again, great work.

30.12.08 03:23:12

@Brian: Ahhh yes I get you. A very clever & inventive use of my plugin. I like it. :)

I love open source my self hence the love of WP. :) Everything would probably be better if it was open source, even Windows. :o

30.12.08 07:11:59

This is both a great plugin as well as some great idea’s!
@Veneficus: Thanks for this, it’s going to come in very handy for a site I’m working on, and,
@Brian: Any chance you’ve got some working code for what you did as well? :D

30.12.08 07:12:59

Sorry,
forums have me in the habit of BB Code in my posts…
and for the double post :)

30.12.08 14:31:41

No worries DanielS. I’m glad you like the plugin & I’ve fixed your BBCode. :P

30.12.08 16:26:02

Hello

How do you use the ‘echo’ to return the URL instead of the ?

Thanks

30.12.08 16:27:05

i meant instead of the –img src–

30.12.08 16:35:43

Hey thanks for the quick response.

This may sound silly, but where does the URL get returned to, so I can use it within a link?

When I use the above code, and view source, I don’t see the post image Url output?

Thanks if you can help :)

30.12.08 16:38:15

i should explain this is how i want to use it:

<a href="">

30.12.08 16:41:02

Ahhh I get you. You want it to echo. I thought you meant return as in store in a variable.

It would just be something like this.

<a href="< ?php the_attached_image('img_size=full&img_tag=false'); ?>">

That should do it. Please ignore the < my code plugin is having a bit of a problem with WP2.7. :lol:

30.12.08 16:50:48

That’s great – thank you very much – works just how I want it but…

Unfortunatley, the


Now appears in the ‘a href’, which in turn doesn’t display the image.

Is it OK to remove the line that generates that from the plugin?

Thanks for your help.

30.12.08 16:51:43

I mean the ‘Generated by’ comment.

How do you insert code in here?!

30.12.08 16:56:34

You use <pre lang=”the language”> code here </pre>.

Thanks for letting me know that was still in there. I use it for testing & had forgotten to take it out. I’ll update the SVN server & you should beable to update via the plugins page soon or you can just remove it your self. ;)

30.12.08 16:59:28

Thank you so much – you’ve saved the day today.

Just one more thing :) If I have more than one image in my post, is it possible to display 2-3 images for example.

Can this be achieved through when you say “I’ve also made it so that you can choose which image is shown by making an image number 1 in the gallery image order” ?

Thanks again

30.12.08 17:03:04

You’re not able to show more than one image, no.

I meant which ever image you set to the top in the WP gallery for the post will be the image that is shown. I’ll put an example in the post as it’s hard to describe properly.

30.12.08 17:09:45

OK cheers, is there any way of choosing to display the second image, for example?

30.12.08 17:12:27

Wll you could just move the second image to the top in the gallery order, that would also change the order in any gallery shortcodes you might be using though.

30.12.08 17:20:11

So close! I was trying to get some functionality like the Get The Image plugin has, whereby you can do this:

“order_of_image

You can choose for the script to grab something other than the first attached image. This only refers to image attachments.”

Not to worry. Your plugin has come in very handy and useful for 90% of my site, and thanks for all your help. Very much appreciated.

[...] – Do you want an image to be shown. This uses my other plugin The Attached Image. It is set to true by default but is error checked so don’t panic if you haven’t got [...]

30.12.08 17:26:39

I hadn’t thought about doing that. I’ll see if I can add something like that into the plugin. :P

30.12.08 16:30:33

@Steve: To return the URL you would use this:

<?php the_attached_image('echo=false&img_tag=false'); ?>

Of course that would return the thumbnail URL. If you want the full or medium URL you would just add the img_size parameter too. So like this:

<?php the_attached_image('echo=false&img_tag=false&img_size=full');

That would return the URL to the full sized image.

30.12.08 17:56:16

@Steve: That feature has been added & seems to be working great. I don’t have a lot of time to bug test at the minute so let me know if you have any problems.

30.12.08 18:48:22

Wow. cool. I’ll take a look now.

Thanks so much.

30.12.08 18:57:32

Perfect!

I’ve now done exactly what I needed to!

Great stuff.

Super speedy – many many thanks for your help :)

30.12.08 19:02:42

No worries Steve. Glad to help. :)

07.01.09 08:12:47

Good lord!! This is exactly what I’ve been looking for. Thanks for the plugin!!

07.01.09 09:00:27

This plugin looks promising, but I would require some sort of a thumbnail caching/storage functionality, so that thumbnail would only be generated once (I have a very big site and I am affraid dynamic generation of thumbs will be very CPU intensive).

Are there any plans to implement this in some future releases?

07.01.09 11:22:00

@Brian: Thanks. :) No Problem.

@Bostjan: Hey there. This plugin does not generate thumbnails, WordPress does all that. All this plugin does is provide a means of pulling the images from WP’s database dynamically which is not normally possible. By that I mean you would normally place it statically inside a post.

I believe you are looking for something like the script called timthumb over at google code:
http://code.google.com/p/timthumb/

You just place link to it via a img tag & provide a width, height, quality & src path. It also has a cache so after the first thumbnail generation it is loaded from cache.

If you want to see it in action then the thumbnails on the front page of my new site Hot Lemons. To see the paths just right click on one of the images and press properties & you’ll see the query to a php script instead of an image path.

Hope that helps. :)

17.01.09 17:57:33

Hello Veneficus Unus,

Thanks for this great plugin. I’ve only recently discovered it, but already found many great uses.

One question: Is it possible to add an Alt attribute to the pictures called by the plugin? Preferably the Description in the WP library. I have tried some things, but wasn’t able to get it working.

Thanks in advance!

17.01.09 18:06:33

Hmmm. I honestly don’t know Jasper. I’ll definitely have a look for you and I’ll get back to you soon. :)

17.01.09 18:44:47

I’ve added that for you Jasper. Just update when the WP plugins server catch up and it should use the image description for the alt tags. :)

19.01.09 10:38:04

Thank you very much!:) Great, I didn’t want to cause you work, sorry for that. I’m going to run an update immediately.

19.01.09 23:21:00

Don’t worry about it. It only took about 5 minutes. :) Let me know if you notice any bugs & I’ll fix them asap. :P

30.01.09 23:32:23

Hi Veneficus Unus,
I stumbled across your plug in by chance – I’m pretty much a newbie to WP and was looking to display my attached image to the latest post and link to the post..well, thought this does it but I probably inserted the code line in the wrong place – hope my question is not too stupid..I use “the morning after” theme, can you please tell me where to add it and in a couple of steps what to do when posting a new post with a new image? cheers Sar.

31.01.09 00:29:19

Cool, thanks for being that quick :)
now – found that bit of code thanks to dreamweaver find..

<a href=”">RSS feed for

Do I stick it at the end or in between? :?

31.01.09 00:33:56

WP is a bit of a pain when posting code into comments. If you can try again but put your code inside these tags:
<pre lang=”php”>
Code Goes Here
</pre>

31.01.09 00:41:10

Tell you what. Send it in an email to pablorobinson[at]gmail[dot]com. It’ll be easier as WP is being a pain. :(

31.01.09 00:10:15

Hey there Sar,

Nope it’s not a stupid question. Sometimes as a WP newbie it can be difficult, but I’ll try and give a quick summary.

I’m not especially familiar with ‘the morning after’ theme but it is the same for all themes so it shouldn’t matter.

First install the plugin, if you don’t know you can either use WP 2.7 install feature or download it open the zip and put the php file in your plugins folder which is in wp-content. I’ll assume you’ve done that though. ;)

Next you open up the main index file in the theme editor of WP. There should be a line that says:

<?php
if(have_posts()) :
while(have_posts()) : the_post();

Or something similar. The line <?php the_attached_image(); ?> should go somewhere within that. Where it goes depends on where you want it to appear. As long as it is after those two php lines it should work though.

To get a link around it you use this line instead of what I wrote above:

<?php the_attached_image('href=true&link=post'); ?>

If you have multiple images attached to a post you can just drag the image you want the plugin to display to the top of the list. That is in the WP gallery, you know the window that comes up when you upload in a post.

Everything else should be done automatically. I will make a video tutorial tomorrow though so if you still have problems, check back tomorrow. :)

01.02.09 08:37:19

I got a problem i can’t get the words to go on the same level as the images so its like this

*image**space*
*text*

i want

*image**text*

01.02.09 12:27:10

@Simon Scott: I’m going to assume you mean like in the image at the top of the post!

It’s not really anything to do with my plugin, but here is the general idea on what to do.

You can have two methods. One allows the text to flow around the image, so it will float to the right & when the picture finishes it will go under the image, or you can make the text float to the right all the way down ignoring the image (like in the example picture at the top of this post).

To do the first one all you need to do is make a CSS rule that applies to the class given to the image tag, this is normally (unless you give a custom one) ‘attached-image’. The rule would be something like:

.attached-image {
    float:left;
}

If you want to do the second option then you will need to place the call to my plugin into a div & place your text in a div side by side, like this:

<div class="attached-image-container">
<?php the_attached_image(); ?>
</div>
<div class="main-post-text">
<?php the_content('READ MORE'); ?>
</div>

The CSS for that would be something like this:

.attached-image-container {
    float:left;
}
.main-post-text {
    float:left;
}

That is exactly what I do to float things. Just remember that you will need to clear your floats or the rest of you site may have some strange problems. <div style="clear:both"></div> that is a clear.

I hope that helps. Let’s me know if you need any more help.

06.02.09 00:15:54

Just wanted to say thanks!! Great work.

06.02.09 12:39:22

No problem Jennifer. Glad you like it. :)

I love your site BTW you have some great tutorials. :D

07.02.09 16:44:46

Hey – so one thing I would like to do is have the option to specify a custom link to the image from within the post/page. You could have the plugin add a custom field (custom meta block) to request what to link to – if the user leaves the field blank – don’t link to anything – if it’s filled in – link to the url they specify in that custom field. Maybe this is specified in the template file to use that custom field value like the_attached_image(“link=custom”) … just a thought. I think I can figure out how to add it if you don’t have time. :) (not sure if that made sense or not) :)

07.02.09 17:03:22

I think I get what you’re after. You want to be able to change where the link points to something you choose instead of the post, image or attachment page. Is that right?

If so, I should be able to add it now for you. :) I’ll post another comment once I’ve uploaded the updated version to the WP plugin repository.

07.02.09 17:16:12

Sorry – me again. :) I couldn’t get the image to show up if I used the att_custom_img in the post. I looked at the plugin and it seemed like it was automatically set to false if it wasn’t specified in the template. (So there wasn’t a check to see if there was a value in the custom field) – just after this line:

if( !isset($image_order) ) $image_order = 1;

I added the following, which fixed this issue…

if (get_post_meta($post->ID, ‘att_custom_img’, true) != “”) $custom_img = true;

07.02.09 17:22:59

Hi,
I don’t think that was a bug since I made the plugin so that you must set custom_img to true in the template and then use the custom field in the post. Why? I haven’t a clue. The way you have changed it to is a lot better so I might go through it and change it at some point it the future. :)

I’ve added the feature you asked for but I’m having a few problems with WP SVN server being an ass at the minute. It should be up soon though.

When it does get onto the SVN. All you need to do is set href=true&link=custom in the template and then use the custom field key ‘att_custom_link’. I hope that works ok. Feel free to shout out any bugs. :)

Edit: The SVN server has updated now to version 1.9 which has the new feature you requested in it. If you can give it a go and tell me if it works that would be a great help. I don’t have access to my localhost at the minute so I’m unable to test it.

07.02.09 17:50:08

So the way it’s set up is that you still have to specify in the template that there will definitely be a custom link or not… but if you add this in the plugin, then you can specify this on a post to post basis:

if (get_post_meta($post->ID, ‘att_custom_link’, true) != “”) {
$link = ‘custom’;
$href = true;
}

(if someone has entered a custom value for the att_custom_link – we can assume they want it linked, and linked to the link they specify…)

07.02.09 18:04:03

Yep, that’s the way the link works at the minute. I’m working on getting it so that you can do it on a post per post basis. That’ll probably be version 2 and will be done very very soon. :)

07.02.09 18:18:02

I have changed the method by which the custom field work to the way you suggested & it works a lot better.

I’ve also added a credit to you in the change log for suggesting it. :) If you can give it a proper test for me and shout out any bug I’d be greatful I’ve only had time to do a quick test unfortunately.

07.02.09 18:27:07

hi. Thanks for plugin

perfect.

07.02.09 18:30:16

Is anyone else having deja vu from the first comment on this post? Oh well. Thanks anyway Baron. :)

07.02.09 18:37:49

First, just wanted to say you’re awesome! Thank you for adding all this stuff… So the only thing is that $href and $link are still defaulted to false, and ‘pic’ in the plugin respectively, and only adding a ‘att_custom_link’ to the post isn’t overriding that.

(I’m heading out in a bit – so if you reply back and I don’t respond right away – I’ll test out anything else you add later today) :D

07.02.09 19:26:14

I had to nip off for some to nom nom nom. :P

Ahhh, I see what you mean. if you don’t define that a link will be present then the custom link won’t override it. I think I’ve just placed the code in the wrong place, let me check…

I had placed the code inside the $href check like a idiot & I’d forgotten to set $href to true. Meh, that’s what lack of sleep will do to you. :lol:

Also, thank you. I don’t think I’ve ever had anyone call me awesome before. :)

I have uploaded the fixed version & changed it’s version number to 2.0.1 since it’s only a minor bug fix.

07.02.09 22:26:33

That works perfectly!! Thank you!!!

07.02.09 22:54:58

No problem Jennifer. :)

08.02.09 14:28:21

Hi,
im just trying to figure out how to get lightbox running with the attached image.

(‘href=true&link=image’) but how to specify rel= ?

08.02.09 14:44:46

It isn’t possible to specify the rel attribute at the minute, but I think lightbox support is extremely important. I just hadn’t thought about it until you mentioned it.

One upgrade coming your way in about 5-10 minutes or so. I’ll post another comment when it’s done.

08.02.09 14:58:01

Right I’ve added that feature. You should be able to get the update as soon as WP’s SVN server updates.

You can specifiy the rel attribute by using rel=whatever in the template call. So (‘href=true&link=image&rel=lightbox’). I’ll update to post with instructions too. :)

Thanks for the suggestion & hope you like the plugin.

08.02.09 15:01:20

wow thanks for the fast answer.

by the way, the plugin is amazing and just running perfect :)

08.02.09 15:07:20

No problem. Glad it works for you. :)

08.02.09 16:05:38

with lightroom integration + ID:

the_attached_image(‘rel=lightbox[' . get_the_ID() . ']&img_size=full&width=760&default=/wp-content/default_images/default.jpg&href=true&link=image’);

08.02.09 16:06:55

Thanks for that little snippet dip. :)

08.02.09 16:19:00

I’d just like to thank everyone for your nice comments & the help with debugging the plugin.

I also want to ask for some more help. If you read my latest post you can see I am looking for subjects to make some ‘tutorials for dummies’ tutorials on. So if you can think of any subjects that you think might be good for novice computer users then please let me know in a comment in this post. Thanks. :)

10.02.09 03:46:11

There probably should be a default image options screen so you don’t have to do it in the loop. Other than that, this is the best plugin for the job I have ever found. Great job.

10.02.09 03:48:31

I’m ashamed to say I don’t know how to make one. :(

I’ll have a hunt around and see if I can find out though.

10.02.09 04:26:34

You may want to modify it so that for the explanation of the default option, its the absolute page starting from your wordpress directory and not your host directory. It took me just a little while to figure that out, but not so bad now that I know.

10.02.09 13:39:18

Sorry about that. I’ll sort that out now.

12.02.09 03:21:39

Hey, you should add the actual field names back in the post above for the general options… they were there yesterday! And I use this page as a reference :P

Thanks.

12.02.09 11:37:40

The reason I took them out was because they are no longer needed thanks to the new options page, but I did mean to add a section to the bottom of the post for the old options. In fact I’m sure I’d done it and I’m not sure why it isn’t there. Hmmm!

I have added them back to the bottom of the post. You should really upgrade to the new version (2.2 at the minute) and use the new options page located inside the appearence tab. It’s a lot easier. Just remember if you do you will need to remove all the parameters out from the function call. If you leave them in it shouldn’t matter since the options will override them, but it’s always best to be safe.

13.02.09 17:12:32

Thanks my friend for the great plugin… you Rock!!

If I may, I have one more suggestion for your next upgrade, that will please I think your SEO-centric fans:
Now that you have gone through the options page, maybe you could add
a default title tag with choices such as: image-name, post-title or post-slug & also a custom field for the title tag.
Maybe the alt tag also, but I think title is more important.

Thanks again ….

13.02.09 17:41:59

An excellent idea ralloux. I’m always looking to make the plugin more SEO friendly since search engines are key these days.

I’m not sure which is more important according to some SEO sites the title tag is, but according to W3C the alt tag is more important. I think I’ll just try and get them both done though.

Look out for it coming in the next day or two. :)

13.02.09 21:31:29

I am glad you liked my idea… Looking forward to your new upgrade…

One more thing though, it seems I cannot make the custom image to work.

Do I have to do something in the template with this new version?
I have removed all the options from the function call as you say, but it keeps on showing an attached image and not the custom one. In the value of the custom field I place just the id of the image I want, (i.e. 188) is that correct??

the custom default image works fine (with the path). Perhaps you should write it a bit more clear for the dummies… because at first I was trying with the id as well.. :fool:

thanks

13.02.09 21:39:55

I think I must have knocked something off somewhere cos you’re right and it doesn’t work. I think the default image might be overriding it. I’ll check that out now. I’ll change the instructions too to make it a little clearer.

Also the new version with the requested feature has just been uploaded. You just caught me after I’d uploaded it or I could have implemented the fixes first. Oh, well. :P

13.02.09 21:49:27

I’m now going to call myself an idiot for about a week. :P

I found the problem. It’s nothing wrong with the code, it’s the instructions. The custom fields key is att_custom_img and not att_custom_image like I had written. :(

I can’t believe I made a mistake like that. I’ve updated that problem & I’ve updated the default image bit to make it a little clearer.

13.02.09 22:07:33

boy!! you ARE fast!!!
great support…
I was not expecting such a quick upgrade… and such a quick response…

many many thanks again..
I’ll check out the new version and get back to you :-)

13.02.09 22:13:07

No problem. :) Let me know if there is any bugs. User input is the only way I can find and fix bugs. :P

13.02.09 23:16:36

me again…

news from the waterfront…

corrections were ok.. stop
custom_img works fine.. stop
alt property/tag works fine.. stop

the title tag:
since it cannot work when the link of the image is set to NO LINK, maybe you could also use the permalink of the post as an option (in the link options), so it becomes more user/seo friendly. Because now, if I understand correctly, it uses the post id.

Besides, in FireFox (and I don’t know maybe in some other browsers as well), you cannot see alt tags, so, if the permalink is not set, you cannot see something useful for the link of the image…

If I try to wrap the whole attached image in a permalink (from within the template) obviously, I end up with two links… one empty class link with the permalink, and one image link with the post id !!! (maybe I get it all wrong here)

ah.. stop!! over and out … for now :-)

13.02.09 23:22:52

Well that’s kinda right. The reason you cannot have a title tag when No Link is set is not because of the coding I could easily have a title tag inside the img tag. The problem is more to do with SEO. Some people say that you shouldn’t have a title attribute inside a image tag and some say you should.

I was always taught that you should use the title attribute in hyperlinks and the alt in images. Although I think maybe it would be better if I allowed a title attribute in the image tag if there is no hyperlink & remove it and place it in the hyperlink if there is one. I think that makes sense. :lol:

I think I’ll try that. :)

13.02.09 23:52:08

So are you no longer looking for a css_class parameter call from the template? I had actually been using it so that on one page template it applied a class to it – and another page template it applied a different class – but now it’s not working.

14.02.09 00:00:17

Hmmm. I’d never thought about that. I guess that’s the problem with an options page, the options will be global.

I have just tried a little jiggery pokery with the coding & I’ve managed to make it so that you can override the options page using the argument call. I’ll put the update on the SVN server after I’ve finished with a few adjustments I’m making. :P

14.02.09 00:33:14

Ok, I’ve added overriding support for css_class & img_size use them as parameters in your function call within your template and it will override the options page. If you leave it blank then the options will take over. Nice. :)

I’ve also jiggled the title & alt thing around a little. If there is a hyperlink then the title attribute will go inside that, if there is no hyperlink, either because of it being set to No Link or because you are using a default image so there isn’t a full image or attachment URL, then it will be put in the img tag. That way there will always be a little pop-up thing when you hover over the image. Smashing. :P

I hope that covers everything. New version is uploaded to SVN and should be available in a few minutes. I can’t believe I’m up to 2.3.2 already.

Any bugs let me know and I’ll fix them tomorrow. It’s 00:32 here and I’m tired.

Thanks for all the help & Jennifer, I hope that gets your custom CSS class working again. :)

14.02.09 20:22:08

big problem with the new option configuration :/

i used the the_attached_image() in index.php AND in single.php but with different options…

index: img_size=full&width=760&default=/wp-content/default_images/default.jpg&href=true&link=post

single: rel=lightbox[' . get_the_ID() . ']&img_size=full&width=760&default=/wp-content/default_images/default.jpg&href=true&link=image

im wondering how to solve this little problem with the new options now… any suggestions?

14.02.09 21:49:56

Sorry about the delay in replying. My OS decided to have a sh*t fit and I had to reinstall.

Right I’ve already fixed that problem with img_size & css_class but I never give the rel attribute a thought. I’ll do that now and upload it to SVN. It should be up within a few minutes. :)

14.02.09 22:05:42

Right that’s been uploaded, just use the old parameter method to specify the rel attribute, the rest of your attributes seem to be the same so you should beable to just specify them in the options.

I will add parameter support for all the different options again, that way you will beable to use the options page & then override the page with the inline parameters. I can’t at the minute since I’m still reloading all my programs etc. I have added rel support though. :)

14.02.09 22:15:05

hehe no problem, support is great :)

what if i had link=post in the index.php and link=image in the single.php?
doesnt work to seperate anymore because link is global now.

14.02.09 22:18:48

It should do. In that one I’ve just uploaded I seperated rel, link and one or two others. I just haven’t updated the docs yet since I’m going to do them all tomorrow & then update the documentation…

I’ve just checked on my localhost & it seems to work ok. Let me know if there is a bug.

14.02.09 22:52:37

i wrote the_attached_image(‘rel=lightbox[]&href=true&link=image’); in my single.php but
it doesnt overwrite the options page…

14.02.09 23:01:31

I’ve just tested your code on my localhost & it works ok. I can’t really help if I can’t replicate the problem. Sorry. :(

All I can suggest is to check that you have the latest version of the plugin (2.3.3). Here is the two sets of code I used in my localhost test.

On index.php the_attached_image(’link=post’);
On single.php the_attached_image('lightbox[]&link=image');

I’m not sure why it’s not working. I didn’t use href=true since it isn’t need anymore but I have tested with href=true included and it doesn’t make any difference. I’m really sorry. :(

15.02.09 03:26:35

Hello — I am trying to locate the link on your page that will allow me to download the folder.

15.02.09 11:39:36

Hi Sandra,

I’m sorry about that. I should really write it on my post. I keep forgetting that new users of WordPress may not know about the repository.

You can get it from the WordPress plugin repository, here is a direct link to my plugin. Or you can download it using the plugin installer built within wordpress 2.8. I don’t host it here because WordPress give plugin authors a SVN account to make it really easy to update your plugin.

Hope that helps. :)

16.02.09 10:26:35

hi ven,
just wanted to leave a message that i got it to work after reinstalling newest version of the plugin and configuring again. the ‘overwrite-function’ is working fine now. thx for the fast support and the effort.

16.02.09 11:10:55

Hi dip,

Thanks for letting me know, and I’m really glad you got it working. I’m going to add support for overide on all of the features later on this week sometime. Thanks for all the help with the bug testing so far & just let me know if you come across anymore. :)

Thanks again. :D

17.02.09 16:39:47

Wow, you did take my advice and make a kick-a$$ options page… really nice job. Seriously, I couldn’t have asked for anything better. A donation from me to you is in your future. Keep up the excellent work.

17.02.09 16:41:48

One thing that I can’t get to work is the alt=”" tag isn’t showing up, even when I select post title. Any advice here?

17.02.09 17:07:39

Thanks you for the complements. I think doing what the users ask is something developers should always do, they are the people that use it. :)

I’m not sure. I’ll have a check into the code and see if I can find a fault. Thanks for letting me know. ;)

Edit: It seems something mysterious has happened to the alt text. I’ll try and figure out what now while I have a little time. Sorry about that. I’ll comment again when the update is done.

17.02.09 17:55:12

Right hopefully that has fixed the problem. I will be updating again with the extra overrides. I just haven’t gotten round to it yet.

Doing too many things at once isn’t adviseable. :lol: Let me know if the update fixes your alt problem, it should be available via WordPress plugin updater in 5-10 minutes or so.

17.02.09 23:35:38

Looks like you missed a space in the code where it adds the alt tag, so I just added it myself ;)

was

		if(!empty($alt_text)) {
			$image .= 'alt="'.$alt_text.'"' ;
		}

now

		if(!empty($alt_text)) {
			$image .= 'alt="'.$alt_text.'" ' ;
		}

Notice the spacve after the double quote, before the single quote at the end.
I think thats the fix. I didnt see the auto-update yet, but look forward to it.

-Eric

17.02.09 23:48:55

Strange. :P

Not sure how that worked, since the problem I managed to find was this. The bit you mentioned looked like this:

get_alt($alt); //Get alt text
if(!empty($alt_text)) {
	$image .= ' alt="'.$alt_text.'"';
}

When it should look like this:

$alt_text = get_alt($alt); //Get alt text
if(!empty($alt_text)) {
	$image .= ' alt="'.$alt_text.'"';
}

I forgot to assign the result of the function to a variable. Doh! :lol: As far as I can tell the space shouldn’t matter, but adding it should hurt either.

If the space really did fix it, great. :) I just don’t get how. :lol:

The update should fix any problems though. :)

17.02.09 23:51:43

Okay, sorry for the spamming of comments, but it still is acting finicky… I have a few wordpress queries that run, which make up my sidebar (visit and youll see where Im using your plugin in the first widget on the sidebar). Its only adding alt=”" to a few of them, and apparently doesn’t handle the multiple query loops well. It may be my fault? but the rest of the plugin is working beautifully.

Anyhow, I’ll let you do your work at your own pace, just not sure why it would do some of them but not all of them.

-Eric

17.02.09 23:53:28

Oh, I didn’t see your timely reply, Ill replace the code above also and report back to you :) Thank you for your dedication.

17.02.09 23:55:14

Oh and, yes, you still have to fix what I found because it was combining 2 tags (the alt and title) so the output was like:

alt="stuff stuff stuff"title="stuff stuff stuff"

and was discounting both of them.

17.02.09 23:56:38

line 284 so you dont have to try to find it yourself

18.02.09 00:09:18

Yeah, I know about the space. Well now I do. :lol: The reason the alt was missing was because the alt text wasn’t being assigned so hopefully if you put that bit of code in & add the space, I’ll add it to the code in a minute, then it should work.

I have tested the plugin with multiple queries (I also help maintain a couple other sites that use my plugin) and it seems to work ok, as long as you have created the new loop in the cocher way. Just in case you want to check that you have I did a tutorial a while ago here. If your loop isn’t done like that then it may be a little finicky because the $post will not be updated properly.

Sorry kinda long winded, but hopefully that will fix it. I’ll add that space now. Also don’t worry about the comments, that’s why they are here. :)

18.02.09 00:12:02

Okay, it’s working great. I’ll report back if I notice anything else.

18.02.09 00:17:24

Ok, great. :)

I’ve added that up to the server it should be version 2.3.5. If you update you shouldn’t notice a difference. Thanks for all the help, and reporting the bug. ;)

By the way, I just want to say I love your site. I love how you’ve used the plugin, it looks great. :)

18.02.09 00:54:42

Thanks, I really appreciate your kind complements and that your plugin works so well!

One more question (lol) I have multiple sections to my site where I’d like a different default picture to display, so I’m trying to use the legacy default=/wp-content/blah/blah.jpeg to overwrite the default default image. Doesn’t seem to be overwriting correctly… Like dip commented previously, it may be corrected with your new code that I have yet to snag, so I’ll wait for it, but just making sure that it can and suppose to work way.

Let me know. Again, it’s really not a problem or critical, but noticed that its not working now

Here’s what I’m trying to do:

< ?php the_attached_image(’default=/wp-content/uploads/2009/01/lauren.jpg’); ?>

Edit: I’ve cleaned up the code & merged the other posts onto this one. Don’t worry about the extra comments it’s easy to clean it up. ;)

18.02.09 12:49:13

Hey there again,

Yeah, I haven’t added the default image to the ‘legacy’ (I like that word) commands yet. I’m just about to do the update now. So look out for it in the next 30 minutes or so. Your code would be correct if I’d added the feature. So once the update is done it should work fine.

By the way, if you want to post code just use:
<pre lang=”php”>
code here
</pre>

18.02.09 13:14:30

Ok update is done. It’s version 2.4 and should be available as soon as WP.org servers catch up. I’ve added legacy support to every parameter and I’ve checked as many as I could. If you do come across any problems please let me know.

Thanks for all the help. :)

18.02.09 20:06:47

I bought you something off of your wish list. I hope you enjoy it! Thanks again for all of your quick and timely support.

If you’d like to help me out too, please use one of these links on your site :)
http://www.roguedeals.com/advertise

18.02.09 20:08:33
18.02.09 20:22:53

Thank you so much and i’ll definately put a link to your site.

No problems. Remember if you have any more problems or requests just drop a comment and I’ll be happy to help. :)

18.02.09 21:46:31

Don’t have time to scan the comments in case this was addressed – but think I found a bug. I didn’t have height or width set for my image – and it wasn’t closing the tag. I had to fix it on my copy because client was wondering why the site was broken (doh) – but the problem was if statement around line 407 – checking width and height… if you don’t have either – you don’t have it just close the img tag… just had to add:
} else {
$image .= ‘” />>’;
}

18.02.09 21:47:30

uhm… wordpress comment made my code come out wrong – but I’m sure you can figure out what I meant :)

18.02.09 22:05:15

Ooops sorry about that. It was a little bit of a case of don’t assume. I assumed that there would never be a case where there would be no width or height since WordPress should always have it, but there are cases where it won’t. Sorry. I’ve added it now & if you want to update it will be on the update server in about 10 minutes.

I apologise to both you and your client. :)

18.02.09 22:07:54

No apologies necessary. This plugin is awesome :D Thank you!

18.02.09 22:08:46

No problem. Always a pleasure. :)

18.02.09 22:09:47

actually – one other quick comment – if you only specify a height and not a width (or vice versa) I’ve seen that IE tends to do some funky stuff… I haven’t played with it enough to figure out why/when that happnes – but thought I’d mention it :)

18.02.09 22:14:22

IE 6 or IE 7. I know about IE 6 I just haven’t the heart to tell everyone using it that they are using the crappest browser ever made. :P

I don’t think there is anything I can do about it, that’s why I’ve made it so most of the time there will be both a width & height available. Unfortunately it’s just IE being crap. :(

19.02.09 14:29:38

I agree. It’s not a coding issue… You should always include both height and width. Never leave it up to the browser to decide what to do.

19.02.09 14:40:07

Yep. Really a decent browser should be able to figure out what the opposite width without much difficulty, but yes I agree you should never leave it to the browser to decide what to do. In the case of images attached to the post I’ve used WordPress to get the width and height, the only time it will be missing is if WordPress doesn’t know. For the default image I’ve used getimagesize() to try and get the width & height, but whether or not that works is dependent upon the users server. Unfortunately. :(

Wow, sometimes I write too much. :P By the way I just want to say a proper thank you to you RougeDeals for buying me something from my wishlist. It’s very kind of you & I’ll be sure to enjoy it. :)

19.02.09 15:40:40

Actually – I think it was IE7 where I saw the issue. It may have also been an issue because the image was getting sized down in the HTML (horrible to do that, believe me I know, but in that particular case we didn’t have a choice). So may be the combination of sizing the image down in HTML and only specifying the width is what triggers it.

In any case, in regards to my images, I don’t know why wordpress doesn’t know the size of the images I was using… weird.

19.02.09 16:14:37

It’s usually really good at keeping track of the sizes of image, rather strange. As for the issue happening in IE7 I’ve never seen it, but I think I’ll give it a little bit of investigation later on.

You’ve intrigued me. :P Also Jennifer I was wondering if you had any little button style links like the RougeDeals one so I could link to your website, if it’s ok too of course? :)

19.02.09 16:51:35

I have checked out IE7 and apart from a few little browser querks it seems to be fine using only one width/height value. IE6 however just dies on it’s ass, really badly, well most of the time anyway.

I’m going to do a little clean of the code later on anyway so hopefully that might help with browser compatibality. I also had an idea for a new feature. Using php/GD to resize the image instead of the browsers javascript & then save it in a cache and show that version of it so it doesn’t stress the server. It’s an idea, but I was wondering if it’s a good idea.

20.02.09 05:00:28

Me again. the legacy img_size doesn’t seem to be over-riding the default. I’m currently developing a carousel slider and I want the images to be bigger than the default thumb size :) Thanks!

20.02.09 13:28:31

Hmmm. Bizarre, I’m having problems replicating the problem, it seems to work ok for me on my test server.

Any chance you could write out the legacy query string your using. It’s the only thing I can think of that could be causing the problem. Sorry. :(

20.02.09 22:26:32

2.4.2 was just pushed to me today. I’ll test again and let you know.

20.02.09 22:31:41

Might not make much difference for your problem, I just noticed a little mistake in the width & height options for the option page.

I’ve been testing the legacy img_size most of today and I can’t see anything that could be causing your problem. If it’s still happening any more info you could give would be great to help with fixing it.

22.02.09 22:32:59

As I understand it, this plugin places one image from the most current blog post anywhere on the blog? Is there a way to put this in a page and have it display one image from the most current 10 posts?

22.02.09 22:51:14

I’m kinda confused… If I understand you correctly then that’s exactly what it does do. I’ve just realized that my intro can be misinterpreted & I’ll have to change it a little.

To give an example. If you have your home page set to show 5 posts & you use this plugin it will show the first image attached to each of those posts. For an example check out celeborama.net which uses it on the front page.

If you want to use it on a page & not on the front page of your blog you will need to make a page template & create a custom loop for the plugin to recieve the post info from. Really you can do anything with the plugin it all depends on your ability to manipulate WordPress’ loop.

If that’s not what you meant let me know and I’ll try and help you some more. ;)

22.02.09 23:55:21

Wow, thanks for the uber-fast reply.
No, I’m looking to display a strip of small images horizontally on a page, with each image linking back to that post on the blog. Like the ‘album’ theme for wordpress: http://www.studiopress.com/themes/album
But I don’t want to run the whole blog like that, I just want one strip of images across a page.

23.02.09 00:05:45

Wordpress seems to be having a strange problem where it insists on needing me to moderate all posts… Bizzare. Anyway. :P

Yes, that’s definitely possible. If you like I can do a tutorial for you, but it will be tomorrow now since it’s just after midnight here in the UK. If that’s ok drop me a reply & I’ll see what I can do for you. ;)

If not I can give you a crash course but it won’t be half as detailed as a tutorial.

Let me know before 1:00AM GMT if you can. :)

23.02.09 00:14:34

No hurry at all. I have been searching for an answer to this for 7 hours today already. I’m just excited as hell that there may be a solution!

23.02.09 00:17:56

Yep. Looking at the link to the theme you gave it has been done in a way similar to what I would have done, but without using my plugin. Using my plugin just makes it alot easier. :)

I’ll do that for you tomorrow, it’ll be a good tutorial for everyone else to look at too so thank you for the question. I sometimes struggle for ideas for tutorials.

Thanks. :)

23.02.09 00:29:12

Thanks a TON! I have to move my blog from a subdirectory to my root and make a wordpress page as my main/splash page, so it’ll take some time to get it running as I want it. I’d rather do it in straight html, but of course html doesn’t read wordpress tags. :P

23.02.09 00:34:00

It’s been soooo long since I’ve wrote static X/HTML I can’t even remember. I still know how to, I just haven’t. :lol:

I’ll sort that out tomorrrow for you, but until then I’m off to bed. :P

23.02.09 12:28:39

I have made that tutorial for you Heather. If you haven’t seen it yet you can find it on the front page or you can go straight to it here.

I hope that is what you are looking for. Unfortunately I haven’t been able to give any screenshot of what it looks like, but it outputs a row of images just like the theme you pointed to. ;)

24.02.09 01:17:59

Did you receive your gift? :) Nothing to report, just checking in.

24.02.09 13:10:37

Yep. I made a post just to thank you. :)

24.02.09 17:43:14

One more stupid question: In IE (the browser that blows), I get a nice nasty blue border on the images because they’re links. I tried to fix that in the page’s css, but it seems to be ignoring that as well as the number of images I want it to show. Anything I’m missing here?

24.02.09 17:54:34

Yeah, I can see it in IE7. Usually all you need to do is this:

a img {
  border:0;
}

OR

img {
  border:0;
}

If that doesn’t work I haven’t the foggiest. :( I’ll have a check around in my book of tricks that I have, but that’s generally what you do to get rid of the border.

26.02.09 05:09:27

Wow, thanks for the post. It really means a lot to me that you’d take time out of your day to thank me. I’m glad you appreciate it because that’s how much I appreciate your plug-in and your support. Everyone should get something nice in return for helping people. The world is too often full of people who just take. I’m glad that I at the very least put a smile on your face. Have fun watching it :)

26.02.09 13:28:41

No problem. I know what you mean. I’m just glad that you like my plugin & very thankful for your gift, and I will most definitely have fun watching it. :)

Remember any problems or feature requests I’m always here to help. ;)

28.02.09 01:36:31

First of all, this is an awesome plugin ! Great work on that.
I have a question though.

Is it perhaps possible somehow to show a static image if there is no attached image?
I have very little to no experience using PHP, but i think it would be possible, although i have absolutely no clue how to do it.

Hope you can answer my question!

28.02.09 12:23:20

Thank you for the compliment. :)

I believe you are refering to showing a default image if no attached image exists? If so you can set one in the options page. Go into the options page and where it says ‘Default Image Path’ put in the path to a default image. The path must start with a forward slash (/) and be relative to the wp-content folder.

You’ll obviously have to create the image using a graphics program and I recommend placing it in the wp-content folder. The path then would be /wp-content/default-image.jpg if the image was called default-image.jpg.

You can also over-ride the default image on a post by post basis using the custom fields. They are a little tricky to explain but you can find out more at the WP Codex. Once you’ve read that use ‘att_default_img’ as the key and the path to the other default image as the value. The path must be like the other one, forward slash (/) then relative from the wp-content folder.

I hope that helps you, if not & I’ve completely misunderstood what you were asking, please let me know. ;)

01.03.09 16:42:44

First I would like to say thank you for taking the time to create such an awesome plug-in.

I’m running into a few minor problems though that I think might be my fault but I can’t figure out what to do.

here’s my template code.

<div class=”post” id=”post-”>

First, I am also using the gallery plugin NextGEN Gallery. This creates a new folder of images which can be accessed from the add image menu in the create/edit post screen.

If I add an image from the NextGEN gallery folder TheAttachedImage won’t display the image at all. It will only show images that I add through the ‘upload from computer’ or ‘media library’ sections. Adding images from links also doesn’t work.
When I do upload from my computer or the media library I can make the image appear the way i want. However after I upload the image I can’t make it go away.
I have tried deleting the image and changing the image to something else, it seems to be cached somewhere I can’t find because the image simply won’t change.
To switch out the image I have to delete the entire post and then rewrite it with a new image.

Can you help me figure out what I’m doing wrong?

01.03.09 17:45:12

First off, thank you & I’m glad you like it. :)

You’re template code didn’t show properly because of WordPress, it can be a bit of a pain when posting HTML in comments, if you can post it between <pre lang=”html”> tags and it should show up ok.

I have a feeling, I’m not sure since I’ve never used NextGEN before, that it stores it’s image in a different database table or in the same one but in such a way that stops WP from seeing them. Since my plugin only works with images uploaded via the WP media uploader that would be the problem.

As for the image still showing after deletion, I’m afraid I’m stumped. I honestly have no idea how an image that has been deleted can still show. It may sound stupid, but maybe it’s actually your browser. If your using Firefox try giving it a Ctrl+F5 to do a hard refresh, it’s solved some of my problems that have been similar. If not have you got WP-SuperCache? That could also be caching the page, although usually if you are logged in it won’t show & it shouldn’t be able to cache images since it usually only caches dynamic data.

I’ll give Next Gen a bit of a check out tomorrow & see if I can add support or something at some point. Sorry if that hasn’t been any help. :( If you do need any more help I certainly try to help though.

01.03.09 20:42:04

I’ve checked out NextGEN gallery & because of the fact I would have to code in database functions to connect to the table used by NextGEN I can’t really add support for it. Mainly because if NextGEN changes it could break my plugin too.

I’ll keep trying to come up with something, but at the minute I can’t. I’m still stumped about your presistant image though. If you do figure out what it was, please let me know. I’d love to know what the solution was. :)

02.03.09 02:52:54

Hi there, firstly, just want to say Great Plugin ! :) Really like it, and am trying to make it work in my site.

However, I am not too familiar with codes & stuff. Hope you can give me some advices here.

I inserted your codes to the appropriate section of the loop – the attached image will appear after the byline of the post.

I have set the homepage to show excerpts only. And the attached image deos show up neatly. However, when I click to the link, which will bring me to the single post page, the ‘attached image’ still appear after the byline. So now, including the original image in the post, I have two same images in the post. I wonder if I did anything wrong, or did i miss anything?

Also, I like the demo you show here (celeborama.net ). For my case, the content (words) appear below the ‘attached image’ at the homepage. What can I do to make the words wrap the images (ie image on the left, and the words on the right) like celeborama.net?

I am sorry if you have answered the same question somewhere. If you did, please just paste a link here. Thanks in advance for your time and help !! :)

02.03.09 13:36:44

Ok first off thank you for your kind words. It’s always nice too hear. :)

Right. The only reason that I can think of for the image showing on both the single post & index (home page) is that you have put the the_attached_image(); call in both template pages. If you only want it to appear on the home page then you only need to place it on the index.php file. If you haven’t done that then posting the code to both your index.php file & single.php file might help. If you do, please post the code in tags like these <pre lang="html"> Code Here </pre>.

You can see the code for making the exact same layout as celeborama.net on this post here. Unfortunately I didn’t really explain it properly since it was just after the Christmas & I think the Sherry was still affecting me, lol. If you have any questions about the code please leave a comment on that post & I’ll help you as much as I can. :)

Again thanks for the question & the compliments and hopefully that will help. Let me know if you need any more help.

03.03.09 02:42:17

Wow ! I did not expect such quick reply !!

I have not got a chance to try yet because still trying to understand your explanation for the codes of celeborama layout. Yet, I thought it is nice to say thank you first for your amazing support. Once I try it, or if any more questions, will drop a line or two here.

Hey, I am sure many people have told you this, yet it does not hurt to hear it one more – You Rock ! ;)

Thanks for your help !

03.03.09 10:21:29

No problem Shirls. It’s good to go through everything slowly, it decreases the chance that mistakes are made, at least for me it does. ;)

Thanks. It has happened once or twice before but it’s nice to hear it again so thanks. :D

Fell free to drop me any questions you have and I’ll answer them as soon as I can. :)

03.03.09 13:37:50

Hi!

Love this plugin, it has really helped with the remodel of my site. However, I have found one hitch with my particular site.

In my posts, most of the photos I use come from a plugin called fotobook. Fotobook allows you to add your facebook photos through the media manager.

These photos do not show up as thumbnails for the post.

I now understand that your plugin looks at the attachment data for the post, and does not actually scan the post for images. Do you think you could include an option to scan the post for images as an option?

03.03.09 14:02:18

Hmmm. Good question. I’m not sure but I can certainly give it a shot for you. It might take a day or two because I’m swamped at the minute, but I’ll give it a go. ;)

Keep checking back, and if you like I can send you an email when I’ve got something done. :)

03.03.09 17:50:24

I have added that feature for you Jake. It is not available through the options page since it is a fairly complex feature. You can use custom fields to set it post by post or you can set it using legacy parameters.

Unfortunately due to a few problems I haven’t worked out yet the default image feature gets disabled for any posts using this feature. So instead of showing a default image if there isn’t an image to show it just cancels and sends back false (useful for programmers).

Check out the instructions either in the docs in the updated version of the plugin or in the post above. There is an entry at the end of the custom fields and at the end of the legacy parameters section. It explains how to use it. If you have any questions, problems or anything else to add let me know. :)

03.03.09 19:28:14

I was wondering if this feature was going to eventually be included, I’m glad to see you’re working on it :) Does/Will it work with any external picture (not just those from facebook)?

03.03.09 19:36:54

It has been done. :) It works with any image from any site.

It works best with images located on the same domain since it can query for the images width & height, but for external images it just grabs it and leaves it to the browser to decided the width & height.

I generally like to include the width & height in the tag but I can’t since getimagesize() is disabled for cross server use on most if not all servers. It tends to be a huge security risk.

So the answer is yes it works with any image & not just facebook. It just works best with images located on the same server as WP until I can figure out a way to get the image sizes from another server. :)

03.03.09 19:59:35

I have managed to get external image sizing working. It might work on some servers it may not on others. It is error checked though so if it doesn’t work it will just try it’s best to make and image tag with out the width & height. :)

04.03.09 14:32:07

Hey,

First off, thanks for your previous answer, i figured it out now. You can see the plugin in working at the site I posted here with. I have one remaining question though. Somehow the ‘alt’ attribute doesn’t show up. At the options page i selected “Image Alternate Text: Image Filename”. Any idea how to fix this ?

Again, I’d like to thank you for this awesome plugin, it is one of the main things in my design. And your support is also fabulous, quick and detailed. Thanks!

04.03.09 15:01:02

No problem Arjan.

I have just updated the plugin to fix that problem with the alt & title attributes. Just a stupid mistake on my part, so thanks for letting me know about it. :)

You should be able to get the update via Wordpress in a few minutes or so. :D Let me know if you have any more problems. ;)

04.03.09 15:55:46

Oh my gosh! Your awesome! Never really had a plugin developer listen to me before!

Thanks! Im going to go check this out. Will report back shortly!

04.03.09 18:04:42

All right, works like a charm now! I have a suggestion for the plugin, but i don’t know if it’s a reasonable thing to ask though. Would it be possible to make it like that, that if you use custom size on the options page, that the picture doesn’t shrink, but just takes a chunk out of the image with those sizes you entered? I don’t know if my explanation is clear enough? Hope to hear it.

Friendly greetings from Finland!

04.03.09 19:01:56

@Jake: No problem Jake, It was a good idea that I’d planned to add ages ago but never got round too. Your request for it gave me the kick up the backside I needed to add it. :)

@Arjan: Glad it’s working now. Unfortunately that isn’t possible because of coding limitations. The width & height are set via the image tag’s width & height attribute which resize the image via the browser your usings built in javascript functions.

I am trying to think a solution & there may be one in a future release so keep watching this space. :)

04.03.09 21:22:22

Hi, is me again :)

I tried looking for home.php & single.php. Apparently, the theme I am using (Atahualpa) does not have them. It only has a main index.php. I went through the index.php, it has lots of lines like this : …..if (is_home()) …OR (is_single()). So, I assume I have to do something like this to exclude some pages and include some pages. I am sorry that I don’t know how to code them, I tried, but obviously failed ! lol

Wonder if you are free to help me a bit here?

Thanks in advance !!

04.03.09 22:08:25

Ahh well that makes it a little simpler. If you only want the image to be shown on the home/index page and not single posts use something like this:

if(is_home()) {
  the_attached_image();
}

instead of:

the_attached_image();

That should work. Don’t worry about it. PHP & Wordpress is a little tricky at first. ;)

05.03.09 14:41:29

Ok, this is working great. Im still having a little problem with the resizing though.

this page is a good example of my different posts.

http://jakegarrison.com/blog/category/general/

I understand that I need to use the att_width & att_height to set the custom size. Do I put this in the custom fields of the post, or set it in the php of the template?

05.03.09 15:01:23

Hi, it works well ! :) Thanks so much !

However, how could I also include category page, achive page and search page (exclude the single post page) in the codes? I tried to use AND or OR (trying hard to pretend I kind of know something ;) ) but give my site a blank page.

Then, I did this :

I know it is stupid lol ! However, this is the only way I know how to do it. It works ok with achive page. But when I click the category from my homepage, then it will show two same images side by side at the category page.

Also, currently, at the homepage, the image is sitting on top of the title & content. I hope to make the image float left, so content can wrap the image on right. I tried to look the template you shared for the celeborama, but can’t figure how I could do it.

Last but not least, I imported XML files from wordpress.org to my new self-hosted site. However, no attached image show up unless I re-upload them. Is that a trick to do this faster?

I am so sorry for so many questions :( I really appreciate your time and help !

05.03.09 15:53:43

@Jake: Well normally WordPress will grab the sizes of the images, but if you are using external images from facebook (or anywhere else) I don’t think the plugin will resize them. I’ll try and add that in for you in a few minutes.

Once I’ve done that you can set the width & height using the keys you mentioned in the custom fields or using the options page or using legacy parameters in the function call. I’ll try and get the resizing done asap for you. :)

@shirls: Ok. First of all the code you posted vanished because of Wordpress. :( When posting code please try to post it like the little note says just above the reply box.

Next to show on all pages but the single page you just do this:

if(!is_single()) {
  the_attached_image();
}

The exclamation mark means is not. So you are saying if it isn’t the single page show the attached image. :)

The floating is kinda tricky. I can’t really tell you what to write because it depends on your site, but I can try and give you the gist of how the whole float thing works.

To float an image and have text flow around it you just need to make a CSS class that instructs the image float. Say you are using the default ‘attached-image’ class that my plugin automatically assigns to the images, the you could just do this in the CSS file, generally called style.css.

img.attached-image {
  float:left;
}

If you want the images to float right instead then change it to float:right;. The problem is that floats have to be cleared to stop strange happenings in other browsers, and it’s good practice anyway.

Find out the class name of the container that holds your post content, it’s generally post or post-content something like that. It will come just before the post header, but just after the start of the post loop. Find the matching CSS rule in the CSS file. Now add this to it’s rules (I’m using post-content as an example):

.post-content {
  width:640px; /* DO NOT COPY these are just example rules */
  margin:10px; /* DO NOT COPY these are just example rules */
  padding:4px; /* DO NOT COPY these are just example rules */
  height:100%; /* Internet Explorer Hack for floats this is the rule you want */
  overflow:hidden; /* Internet Explorer Hack for floats this is the rule you want */
}

If you want to float it like on Celeb O Rama, so that the text stays to the right and doesn’t flow underneath the image, it’s kinda tricky but it’s based on the same idea. Instead of floating the image you place the image in a <div> and the text content in a <div> and float them both. You will still need the clear in the content container as well.

I hope that helps, no matter how hard I try floating still gets confusing to explain but hopefully that will help you. If you still have problems give me another shout & I’ll see if I can help some more.

05.03.09 16:09:19

@Jake: Ok, I’ve completed that fix for you. It should be version 2.4.6 and will be available via WP plugin update as soon as the SVN server updates. Hope that fixes it & sorry. I guess I hadn’t had enough coffee. :P

05.03.09 18:53:49

Hello, I’m making a theme and trying to auto attach thumbnails. I’ve made a post, and attached an image via the Media Gallery.
My code is: http://pastebin.ca/1353717

the plugin is enabled, the image appears on the single post. If I type ” <img src=”">”
the image is not found, and it is trying to link to the root of my wordpress install. Weird?

05.03.09 19:03:28

I’m not exactly sure what you are asking but the plugin is meant to output an image tag pointing to the first attached image. You can echo out the path to the image to put in your own image tag if that’s what you want. You just turn generate an image tag to false in the options page & it will output the path to the image instead.

If that’s not what you meant please explain a little more & I’ll get back to ya. :)

05.03.09 19:54:25

Sorry. Ok. So it now works! Kinda. It’ll show the default thumbnail (specified in your plugin options) but wont use any images in our posts.

Eg: http://davepress.org.uk/ukti/2009/03/trial/ has an image in it, but the thumbnail is still the default.

Any ideas?

05.03.09 20:10:42

Without seeing the template, I can’t really figure it out. I can give my best guess though.

My best guess is that in the custom loop parts of the theme, the $post array has not been repopulated for each new custom loop. Most people forget about it but lost of posts that alter or add to post content need them.

At some point I’ll try and add something to compensate. Untill then if you can post your template code to something like pastebin so I can see it I’ll beable to tell you if that’s the problem. If not I’ll see what else I can find.

Sorry about the problems & I hope we can fix them quickly for you. :)

05.03.09 20:22:40

what parts of the template do you require?

05.03.09 20:38:37

If it’s a normal template & the images should be appearing where the UTI crowns are it would just be the entire index.php file of the template.

05.03.09 20:41:57

here’s the index.php – http://pastebin.ca/1353789

the theme is mimbo pro.

05.03.09 21:09:35

Wow I didn’t recognize it. :lol:

Ok first we’ll start with this bit:

<?php
                //Interacts with control panel to determine lead category
                        $bm_categories = get_categories('hide_empty=0');
                        $mim_feature = get_settings( "mim_feature" );
                        if( $mim_feature == 0 ) { $mim_feature = $bm_categories[ 0 ]->cat_ID; }
                        query_posts( 'showposts=1&cat=' . $mim_feature );
                        while (have_posts()) : the_post();
                ?>
                <?php the_attached_image(); ?>
                </div>

The problem is that query_posts in my experience doesn’t reset the $post array. So you have to do it manually. I haven’t been able to test this since I’m not at my localhost but it should work.

Everytime you use the_attached_image() in a loop that isn’t the main wordpress one (another words if it doesn’t use the query settings definied in the options pages of wordpress) then you will need to replace the query_posts that is in the template with a new WP_Query instead. Here is what the first query from your template would look like:

//Interacts with control panel to determine lead category
$bm_categories = get_categories('hide_empty=0');
$mim_feature = get_settings( "mim_feature" );
if( $mim_feature == 0 ) { $mim_feature = $bm_categories[ 0 ]->cat_ID; }
$temp = $wp_query; //store the old WP query
$wp_query = null; //Nullify the $wp_query variable
$wp_query = new WP_Query(); //create a new query
$wp_query->query(showposts=1&cat=' . $mim_feature); //Change the query to whatever it said in the template
$temp_posts = $posts; //store the old posts array
$posts = null; //nullify the posts array
$posts = $wp_query->posts; //store the new posts array
$tmp_post = $post;
$post = null;
while (have_posts()) : the_post();

After the while you would need to add this little extra bit. It must come straight after the the_post();

$post = $wp_query->post;

Then after the while loop ends (line 35 in your template) you need to reset everything like this:

$wp_query = null;
$wp_query = $temp;
$posts = null;
$posts = $temp_posts;
$post = null;
$post = $temp_post;

Unfotunately you’ll have to do that everytime changing the query each time. The reason is simply because WP doesn’t update the $post or $posts array when using query_posts() and they are the only two variables plugin developers can use to grab the current post. Using this method updates & then restores those variables each time meaning the plugins can use those arrays properly. I use it on Celeb O Rama & the site Purrfect Gifts uses it quite extensively along with my plugin to make the Carousel.

If you have any other questions or are still confused about making the custom loops let me know & I’ll see what I can do to help. :)

05.03.09 21:16:52

cool! I’ll try it now. What should this line in your code be:

$wp_query->query(showposts=1&cat=' . $mim_feature); //Change the query to whatever it said in the template

seems to have an open ‘

05.03.09 21:19:40

whoops, sorry, just re-read the comments … !

05.03.09 21:24:53

I’m probably being *really* dense, so I apologize.

this code you pasted:

		cat_ID; }
	$temp = $wp_query; //store the old WP query
	$wp_query = null; //Nullify the $wp_query variable
	$wp_query = new WP_Query(); //create a new query
	$wp_query->query(showposts=1&cat=3 $mim_feature); //Change the query to whatever it said in the template
	$temp_posts = $posts; //store the old posts array
	$posts = null; //nullify the posts array
	$posts = $wp_query->posts; //store the new posts array
	$tmp_post = $post;
	$post = null;
	while (have_posts()) : the_post();
	$post = $wp_query->post;

		?>

we want to show the category with id “3″ — but wordpress says:
Parse error: syntax error, unexpected ‘=’ in /index.php on line 17

what are we doing that is daft? thx :)

05.03.09 22:01:34

:lol: Nope you’re not being dense. That was actually my fault & you were right the first time, I do have a unopened quote. The line:

$wp_query->query(showposts=1&cat=3 $mim_feature);

should be:

$wp_query->query('showposts=1&cat='.$mim_feature);

I’m assuming the theme Mambo pro has some sort of options page where you can set the category this shows (that’s what $mim_feature is for. :)

Give that a try & let me know. :)

06.03.09 09:03:53

still just the default thumbnail (although the code now runs and doesnt error). The post content is simply a html image tag:


so I don’t think its a problem with the post…. Any other ideas?

Peter

06.03.09 13:50:06

Your code vanished… Damn I hate WordPress sometimes. :P

I did manage to give the code a go on my localhost this morning & when using query_posts(); it doesn’t work properly (it trys to use the posts from the main loop), but when I use the code I gave to you it works correctly. So I’m not sure why the image isn’t showing… I’m afraid you have me beat. :( Sorry.

The only thing I can suggest is that it is still something to do with the way the theme works since there are already quite a few people using it, including myself. :) You could send me the whole theme & I’ll try & get it working on my local server, other than that I’m afraid I’m stumped. I’m really sorry. :(

06.03.09 15:21:31

@Peter C: I have made an alteration to the plugin to fix any problems with query_posts(). It shouldn’t have any problems with the $post array now. So it should work without any problems.

If it doesn’t fix the problem please consider sending me a copy of your theme via email since it means there is a major problem with that theme and my plugin & it would be a great help to try & fix the problem. You can send to admin[at]return-true[dot]com.

Thanks & you should be able to get the updated version (2.4.7) from the WP repository in a few minutes time.

06.03.09 17:27:18

Hi,
I’ve been following you and Peter C, because I’ve got the same issue, only I’m using the default wordpress theme in which I’ve customised the HTML only. I’ve upgraded to v2.4.7 a minute ago too, but still no luck.

I’ve done some debugging and have narrowed it down to the following:
Works when I create a new post, and upload an image into the post.
Doesn’t work when I create a new post and insert an existing image from the media library (i just get my default pic).

The website in question is http://lisafaye.robholmes.net

I’m a PHP developer if that helps, so feel free to throw any jargon at me you need to, or ask any questions about setup, etc.

Hope you can help. Thanks,
Rob

06.03.09 17:42:57

Hi there Rob.

By insert another pic from the media library do you mean using the custom fields to show a picture by ID? That’s the only way to get WP to show a picture attached to another post. If so there may be a problem there & I’ll see if I can find it and fix it.

On a small side note I really like that site. :)

06.03.09 17:55:33

Thanks, it’s for a friend of mine (Lisa Faye… doh, was that obvious? lol)

When I say insert a pic from the media library i mean as follows:
In the edit/new post screen, I click on the ‘Add an image’ link which brings up a modal box with 3 tabs. I click on the media library tab, then click ‘Show’ for the image I need, then click on ‘Insert into post’ button.

This puts the image into the post, but by looking at the database table ‘posts’, it doesn’t create an attachment record, but just inserts an img tag into the post_content, with the src going straight to the images location.

eg. the img tag looks like this:


Hope this helps a little more.

Thank you, I really appreciate your help on this :-)

06.03.09 17:57:28

Ok, img tag looks like this:


                       
06.03.09 17:58:11

Ok, giving up on trying to show you the tag, wordpress isn’t playing ball ;-)

06.03.09 18:24:36

Woohoo… I’ve found the bug! :-) I use bug lightly as I’ve done this many a time in my own code.

On line 264:
if($in_post_image != false) {
should be:
if($in_post_image == false) {

It then regexs to the first image it finds, which now pulls out the first image in my post.

At least I hope that’s it, as I haven’t had a chance to test in other scenarios, but I believe that’s it.

I can feel a v2.4.8 on it’s way.

06.03.09 18:30:37

That’s created another bug, sorry. Now the default image doesn’t get show if there is no image. I’m working on it :-)

06.03.09 18:34:21

Haha. Nope that’s not a bug. It does do what you want but you need to use the options.

The plugin has three options. First is to show and image that is attached to the current post, second is to show any image by using the custom fields in the post and the key att_custom_img & finally using the att_in_post_image custom field key which will find the first image tag in the content of the post using some fancy preg match stuff.

You just pick which thing you need. I hope that helps. I’m thinking of making a video tutorial soon to show what the plugin can do. :)

06.03.09 18:47:35

:-( ok, *hands held high* my mistake.

I thought the plugin would do it all in that order, but I didnt realise you had to have a custom field to make it look through the post.

Can this be added as an option in the Appearance->The_Attached_Image area, because that would be really handy to have it use the regex method by default, if it fails on all the other methods?

Thanks for all you’re help, and sorry if I sounded cocky, I really didn’t mean to, I was just trying to help.

06.03.09 18:53:23

No problem Rob. I’m glad you tried to help. :)

I hadn’t thought about having it drop back to the regex before dropping to the default. It’s a really, really good idea so thanks for that. I’ll add that in tomorrow. So look out for 2.4.8 ;)

Like I said no problem. It’s nice that you wanted to help. Feel free to drop by if you need anything else or have any questions about the plugin. By the way I think I’m in love with that site… It’s odd since I don’t really like pink (you know being a bloke and all) but I really like it. :P

Thanks again for that gem of a suggestion & I’ll get that added tomorrow. :)

06.03.09 19:59:44

Hi,

Thanks a lot for your plugin: ‘it saves my website’.
I just wonder about something:
- if I put some image in my post it is working
- but if I put an image coming from nextgen gallery, the attached the image plugin doesn’t display anything.
Is their any way to make it work with nextgen image gallery?

Thanks a lot

06.03.09 20:33:34

Unfotunately not Marie. Sorry. It’s all to do with the fact NextGen stores images in a different way to WordPress. I’m still looking at ways to make some sort of bridge but at the moment there is no way to do it.

Sorry Marie.

08.03.09 14:12:11

Hi Veneficus. By doing the small tweak:

On line 264:
if($in_post_image != false) {
should be:
if($in_post_image == false) {

as discussed above, it now grabs images — awesome! but ….

it now won’t use the default image if it can’t find any images in the post.

Do we have to use a custom field to make it use the default post? Do we have to usually use a custom field to make it search for images in the posts?

08.03.09 14:26:18

As mentioned to Rob the plugin is designed so that grabbing the attached image is it’s primary function. The if($in_post_image != false) { is intentional since a few lines before that it checks to see if the custom field att_in_post_image is set. It takes the number of the image you would like it to show from the post. So if you use 1 it will look for the first image in the post. If it can’t find one it will return blank.

I am going to do an update a little later (I should have done it yesterday, but the site was hacked & I was sorting that out) which will allow you to turn this feature on & off from the options page. It will always be available on a post by post basis using custom fields. If you want it to do this function all the time (another words not try for the attached image & always grab an image from the post) then until I have added the option in the options page you can add in_post_image=1 into the function call as a legacy parameter. Change 1 for which ever image you want it to look for.

I hope that helps you out a little. I’ll get that update done a little later.

08.03.09 17:03:52

I have now added the checkbox feature in the options page to turn on & off the in post image system. Just press the checkbox & type a number for what image it should try to grab from the post. It will completely bypass the normal functionality of the plugin though.

Please, please, please, please read the documentation. It saves me & you a lot of time. I’ll still answer any questions, but it helps both you & me if you read the docs & make sure the answer isn’t in there before you ask any questions.

10.03.09 13:33:21

Thanks a lot for taking the time to answer.
I am definitly looking forward to see that bridge!

Marie

10.03.09 14:16:32

No problem Marie.

I’ll definitely try to get a bridge done at some point, but I can’t say when. Sorry.

14.03.09 02:35:18

Is it there a way to check if a post has or not an image attached to it?

From The loop I’d like to do different things depending if the post has or not one or more images attached to it.

Thanks

[...] Attached Image is a simple plugin that packs quite a punch… …..read more Download Plugin! Plugin Owner: Paul Robinson Homepage: Visit Plugin’s Website Version [...]

14.03.09 10:58:13

There isn’t an exclusive way to check, by that I mean a way that would return true or false. However you could turn on returning in the options menu, instead of echoing the result & if you have the default image turned off you could check to see if the result is empty. Of course that isn’t any help if you want the default image to show still.

I might add a function to the plugin called have_attached_image() which returns true or false depending on whether there is an attached image or not. In fact I’ll add that now. :)

14.03.09 11:14:22

I have added that new version to the WP SVN plugins server & you should be able to grab it in a few minutes. Just use have_attached_image() to check. It will return true if images are available & false if they aren’t.

Hope that helps you Matt. :)

04.05.09 19:40:33

Hello,

First off-GREAT plugin!

My question is I was wondering if there was a way to get the thumbnails that are created automatically to get re-built? I have altered some of the images since I first uploaded them and the thumbnail pics shown are still the old pictures.

Any ideas?

thx,

Mike

04.05.09 20:03:02

Hi,

My plugin doesn’t have any sort of caching built into it so if you have deleted the image it should automatically change. I remember someone else having this problem, but we never figured out what caused it.

My best guess was wp-supercache but if you delete the image it shouldn’t be able to show regardless of caching. You could also check your browsers cache (especially if you use FireFox). I can definitely comfirm it isn’t the plugin though.

Also, probably a stupid question, but have you deleted the old image (in the uploader) and uploaded the new one.

04.05.09 22:00:23

Actually, it wasnt a stupid question at all…I have no idea why I didnt think of deleting the old media files-LOL

Anyway, that did the trick and everything is perfect.

Thanks a bunch!

05.05.09 11:35:56

:lol: No problem. :)

15.05.09 01:44:02

Hey, thanks for making this plugin. It has all the features I’ve been trying to figure out by hand. One question though: is there a way to show all images attached to a post? Or just the first attachment in one call, and in another, show the remaining attachments as thumbs?

15.05.09 11:33:30

Hey there Ahni,

You don’t really need to use my plugin for that WordPress has something called the Gallery Shortcode built in for doing what you have asked. To do it in your template just find where you wish your images to show everytime & place . I use it on my other site.

I hope that helps a little. :)

15.05.09 17:26:14

Thanks for getting back so quick. Do you mean


? This might just work, though I’ll still need to use your plugin for images everywhere else on my site. Thanks!

15.05.09 17:26:57

oy, that didn’t work. I meant: http://codex.wordpress.org/Gallery_Shortcode

15.05.09 19:02:51

Yep

 <?php echo do_shortcode('[gallery]'); ?>

That’s the bit I meant. WP is a bit of a pain when posting code. Sorry for the problems. :(

16.05.09 00:57:59

Well, it’s working great so far :) Added in an image.php template and now I’m feeling all professional. One more quick question though…. Umm, how come the sky is blue?

haha, just kidding. Take care.

16.05.09 11:22:58

Haha, the odd thing is I was about to answer that question. Then I finished reading you comment & realised you were joking. :)

Glad it’s working for you & yep all of a sudden you get a really professional feel when you add images. :D

20.05.09 11:48:40

Just wanted to drop a line thanking you for this plugin. It does exactly what was essential to my preferred layout. I do think I’ll be donating! Cheers.

20.05.09 12:06:58

No problem J.

Thanks for any donations too. They all help towards the further development of this plugin & keeping the website running. :)

28.05.09 20:08:22

Hello, congratulation for such a great script. I made some hack to create_default_image function in order to be aware of config value in "Generate An Image Tag". For default this function always return an img tag, so here i share the hack

(Using v2.4.9 on WP-2.7.1 and Virtual multiblog v2.5)

In file the-attached-image.php line 559 change line

$image = '<img src="'.get_bloginfo('url').$default.'" class="'.$css_class.'" ';

to

// Start of hack
$img_tag = get_option('att_img_tag');

if($img_tag === true || $img_tag == 'true')
{ //Do they want an image tag along with setting the height & width.
$image = '<img src="'.get_bloginfo('url').$default.'" class="'.$css_class.'" ';
}
else
{
$image = get_bloginfo('url').$default;
return $image;
}
// End of hack

29.05.09 19:07:18

Hi There,

The Plugin looks exactly what I need but I can’t seem to make it work.
It won’t render any images.
No errors. Just nothing.

Dmitry

30.05.09 11:10:56

@Eduardo: Sorry for not replying, my emails telling me I’ve recieved a comment are being classed as spam by Gmail. :(

Thanks for the fix. I hadn’t realised there was a bug. I’ll add that fix in asap. :)

@dmitry: I know this seems a bit of a cop-out but without any errors I cannot help you. The only think I can think of is that after installing the plugin you haven’t added the function call into your WP template. You need to add into your template whereever you want the image to apppear.

If you can give any more info it would help alot. ;)

[...] Wordpress Plugin The Attached Image Posted by root 9 minutes ago (http://return-true.com) Img size changes image size to be pulled back by wordpress options are thumb medium then i finished reading you comment amp realised you were joking anna paquin memorial day celebration x5 middot sarah chalke scrubs season 8 promos x6 copyright 2009 retur Discuss  |  Bury |  News | Wordpress Plugin The Attached Image [...]

12.06.09 14:05:45

Awesome plugin. I’m trying to escape PostThumbs, but there’s one thing stopping me. (btw, PostThumbs will cause your site to get hacked).

When I try to use the call multiple times on my home.php, it only shows the image of the first query. Basically, I want to call the medium size once for my main category. And then I have 8 other queries on the same page that will each call the function for the thumb size.

Here’s the second query on my home.php (it just shows the same image from the first query 13 times)

have_posts()) : $recent->the_post();?>

<a href="">

Am i doing something wrong. Thanks.

12.06.09 19:17:25

Hi retsek,

I think most of your code got lost. Probably WP being a pain with code in it’s comments again. If you can try the code again I’ll see if I can help.

Normally secondary queries don’t cause much of a problem with the plugin since it get’s the query directly & creates new variables as to not destroy the original one. There was another person back in the comments a little while ago who had similar problems & we never did figure out the problem, since I could never replicate it.

I will certainly do anything I can to help though if you can comment the code again. If it doesn’t work again try sending it to my email in a txt file at pablorobinson [at] gmail [dot] com. Thanks.

13.06.09 03:33:48

Hey,

Thanks. I sent you an email.

17.06.09 15:35:57

Works great, thank you

17.06.09 15:37:10

No problem. ;)

02.07.09 23:24:06

Just a note:
it seems as though upgrading to WP 2.8 breaks this plugin. I recently upgraded my site to WP 2.8 and I was using the older version of this plugin. After the upgrade the plugin stopped working. So I then upgraded to the latest version of this plugin and it still isn’t working. Has anyone else experienced this problem?

BD

03.07.09 10:22:29

Hi,

WordPress 2.8 compat has been tested by me & other users of the plugin with no problems. The upgrade to 2.9 when it’s released probably will due to the planned changes in the media section, but for now the plugin still works correctly.

What exactly is the problem you are getting?

[...] You can also have multiple instances of the function call by passing parameters.You can also pass the parameters of the options available through the plugins options page, Check out the list of supported parameters here. [...]

[...] da página opções plugins, Confira a lista de parâmetros suportados aqui. Download A imagem anexada Plugin | Plugin Documentação Comments [0] Print [...]

08.07.09 14:06:13

Great Plugin and it seems that it will save me a lot of time.

I have one problem with it:
the_attached_image(‘link=none&href=false&img_size=medium&link=image&css_class=mb&image_order=1′);

I try to change the output that it online displays the image – no link!
I always get a linked image!
What am I doing wrong?

Cheers,
Sebastian

08.07.09 14:10:55

Hi Sebastian,

I’ll have a check in the code to make sure there isn’t a problem, but from looking at the code snippet you gave my immediate thoughts are this, here is the snippet you gave:

the_attached_image(’link=none&href=false&img_size=medium&link=image&css_class=mb&image_order=1?);

You have set the link to none at the start but then you have set it to image again later. That is probably what is wrong. ;) If not let me know & I’ll see what else I can find. :)

09.07.09 14:33:43

Hello, i trying to make your plugin work with autothumb plugin, all my images urls are like: http://www.downloadingall.net/wp-content/plugins/autothumb/image.php?src=http://i43.tinypic.com/xmvgqu.jpg&w=250&aoe=1&hash=b9b211babce6bef014f04242732c753d

And i cant figure out how to make a auto thumb of this images ! thanks

09.07.09 15:19:34

Hi,
from the look of the autothumb plugin it automatically parses image tags with any parameters, such as ?zc=1&width=500, etc & redirects them to the thumbnail making script. That would mean normally mean you could just use my plugin call, but from looking at the plugin authors comments it seems it runs on the_content hook which means it wouldn’t work.

Here is a possible solution for you though. In your template where you are calling my plugin do this instead:

<?php
$img = the_attached_image('img_size=medium&echo=false&link=none');
echo getphpthumburl($img, 'w=350&h=225&zc=1');
?>

I hope that makes sense. Because the autothumb plugin will ignore any img tags in the template you have to call it directly. I think that should work. I can’t test it because I don’t have autothumb & don’t have anyway to test it right at this minute.

Hope it works though. :)

09.07.09 21:17:37

Hey Veneficus Unus,

thank you for the hint. I have already figured out that it was the wrong order.
That’s the reason why I came not until today. Today I am looking for some more parameters because I am working on complex foreach() construction to show images of a post in depandence of custom fields and predefinded amounts of images to show. Ouf, it’s really hard and the solution has nothing todo with your great plugin which helped me a lot.
Many thanks again for sharing!

09.07.09 21:19:12

No problem, and good luck. :)

11.07.09 01:58:11

The attached image plugin stopped working after my upgrade to 2.8 — I am now on 2.8.1 and it continues to not work.

Prior to the upgrade, I had been successfully using the plugin 3 times on the index.php using the following:


<a class="title_link" id="titlelink-" href="">

I have 3 loops, each one grabs the latest post in a category — see category=xx bit above.

Note that all the regular Wordpress stuff works. ie, Ive tested that the_loop is set up right, and it is.

The 3 images are now all the same, and are coming from the most recent post over-all, NOT the most recent post in each category.

11.07.09 01:58:51

and your pre tags dont work, either. I used them properly and it mangled my code.

11.07.09 02:06:11

i fixed this by not using wp_query to get the post.

11.07.09 11:22:40

Hey Coconut,

The pre tags do work but WordPress has an awful habit of mangling code written by non members for some reason. Something I wish they would sort out by integrating GeShi into the core, probably not going to happen though. Also you should replace <pre lang=”language”> with the language you are writing in. So PHP in this case.

Depending on how your wp_query was made it may have broken because of the update. I have been away from coding for a little while & haven’t had much time to check things, but I’ll check the plugin with 2.8 & 2.8.1 a bit more than I already have to make sure there isn’t any strange things going on.

14.07.09 07:34:20

Hey there! Any luck with 2.8?

Here’s how I had it invoked and it worked in 2.7, but now it doesn’t:

have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>

Is there anything that I could add on my end to the_attached_image call to help it see the image for the first post of the category in question?

14.07.09 11:33:43

Hi,

It looks like WP’s comments has destroyed the code you wrote in the comment. From the look of it though you have used a $my_query = new WP_Query('query') which doesn’t work because the attached image taps directly into the main WP query, which is $wp_query. If you run a query that way it shouldn’t work regardless of the WP version you are running. I will do a tutorial soon showing how I was taught the best way to do it was.

I have tested the plugin extensively in 2.8 & 2.8.1 and there are no problems, I have also asked a few people who are using it on their clients sites and they have no problems in 2.8. For instance the plugin runs the images in the javascript slideshow on this test site and that is running 2.8 (just look in the source code).

I will keep looking, but it looks like it is something else, what I don’t know.

15.07.09 03:55:32

Hmmm.. that is odd. Just so you know too, what the code executes on our site (pulling the most recent post from that category) still works in 2.8 too. Let me know if you find anything!

15.07.09 08:25:04

Yeah the query should still work, but so should the plugin as far as I can see. I just meant that The Attached Image shouldn’t work properly with a query made like that. (See my most recent blog post).

I have absolutely no idea why it isn’t working. I spent most of yesterday trying to break it in 2.8.1 and couldn’t. If you could check for any PHP errors (they are normally disabled) it would be really helpful. I’ll keep trying, but as far as I can see there isn’t any problems. :(

16.07.09 08:53:04

Hi,

I think the problem is related to the fact that you declare $wp_query as a global variable in your ‘the_attached_image’ function. An alternative solution would be to have the function take the users custom query as an argument. I had a problem where the same image was repeated in my template after upgrading to 2.8 but fixed it by naming my query $wp_query.

Luke.

16.07.09 09:03:35

Hi Luke,

Yeah, the declaration was done on purpose since without it the same problem you had seemed to happen regardless of the query used. I made a post about another reason I used $wp_query too.

It a good idea though to use the custom query as an argument. As easy as it sounds I never thought about it. Thanks for the idea & I’ll add it as soon as I can. :)

18.07.09 00:46:36

Would it be possible to list the latest 3 posts from a category with the thumbnail included?

18.07.09 09:40:36

If you are asking what I think you are then you would do it like this:

$my_query = new WP_Query('showposts=3&cat=3');
while($my_query->have_posts()) : $my_query->the_post();
    //any other post functions you like. For example the_title(); the_permalink(); etc...
    the_attached_image('img_size=thumb', $my_query);
endwhile;

Just replace the 'cat=3' bit with the ID of the category you want to show (you can always use category_name=catname instead). Look on the WordPress codex for the loop for the other functions to use, if you don’t know them, within the loop. Such as the_title().

Hope that helps. :)

18.07.09 11:20:58

@Veneficus Unus

Thanks for the code, not quite what I have.

<a class="title_link" id="titlelink-” href=”">

Do you know the hook to show the post text?

18.07.09 11:23:08

Ok, can I just email you?

18.07.09 11:30:47

yep feel free at pablorobinson at gmail dot com. I’m trying to sort out the pain in the ass that is WordPress and posting comments but so far I havent had much time or much luck. :(

feel free to email me though and I’ll help. ;)

18.07.09 15:52:12

Hello. I wish I had the option:

the image is added to the feeds.

Without this option my feeds do not have image.
Thank you for creating this great plugin

18.07.09 16:04:31

Hi Gabriel,

I’ve never though of putting the image into the feed. I’d have to check out how to do it but I’ll try & add it into the next update for you. Should be done within the next week or two.

18.07.09 16:29:53

Veneficus Unus, thank you very much.

There is a plugin that does this: ( http://web-argument.com/wp-rss-images-wordpress-plugin/ ) but does not insert image, insert link

I hope this information helps.

Thanks, again

18.07.09 16:39:23

Thanks that should help a lot. It’s always nice to be able to reference a script that has part of the workings that would be needed. :)

22.07.09 15:54:31

Veneficus Unus. I update the plugin. It works very well.

Now the images are attached as files, would like to attach as images,
in the same way you see on the website.

Thanks.

22.07.09 16:09:01

Hi Gabriel.

I’m still working on how to do that, I’ve been trying the way recommended on a few websites but none of them seem to work, or have been discontinued as of recent versions of WP. I figured that would be better than nothing for the minute.

Don’t worry I’ll get it working eventually. :)

22.07.09 17:14:35

Veneficus Unus, your plugin is excellent. I am glad that you continue working on it.. Thank you very much.

22.07.09 17:17:42

No problem. :)

27.07.09 21:06:23

Hi
This plugin is excellent – and hopefully it can do even what I hope for.
Actually I’m looking for a replacement for an outdated post-thumb plugin. Point is: With the old plugin I inserted a piece of code in our templates (just as I must do to use your attached-image). Then, the first time the post was viewed, a thumbnail from the post’s top image was generated.
In other words: I hope it’s somehow possible to replace the post-thumb code with some attach-image code, and voilà! – all the thumbs appear as they should.
With standard use it seems that I have to upload an image to any existing post to make a thumbnail appear. If so, I will have to do this task for all the ca 250 posts on our site – I hope not. (Or is there some other way I can achieve this, maybe together with some other plugin?)
Maybe I should add, since our site is in Norwegian, that it isn’t a blog but a travel guide, with fairly static posts which are visited regardless of when they where published. Today it works like this: http://www.dolcevita.no/umbria/
I hope that you can help me on…
Thanks,
Kjetil

27.07.09 21:18:37

Hi,

This plugin is basically an updated version of an old plugin that grabbed the first image attached to a post. Meaning the image was uploaded via WordPress’ inbuilt image uploader. If your images were not uploaded to each post (or page) then I’m afraid this plugin won’t be any help.

If I understand you correctly the post-thumbs plugin grabbed the first image inserted (rather than uploaded) into the post (or page) and made a thumbnail from it? You can enable a functionallity on the plugin that does something similar (the checkbox on the top of the options page for the plugin) I’m not sure if that is what you are looking for though.

I hope that answers your question, not sure if it helps though, sorry. If it doesn’t just comment again & I’ll see how else I can help. :)

27.07.09 21:30:28

Thanks a lot
- the all-time quickest response I’ve got during two years with WP! :o )
All the images are uploaded using WP’s upload function. The problem, it seems, is that the images are already there. So, I need the plugin to display thumbs from images already in the posts, not just in new posts.
If this isn’t possible, I will have to edit each post – delete the top image – re-upload the same image – and click save.
I was hoping to avoid that – but maybe it’s un-avoidable.
Hope I explain myself precisely enough.
:-)

27.07.09 21:33:37

Ahhh I get what you mean, you have inserting the images in <img> tag inside the posts already. Unfortunately you’ll have to go through all the posts & remove the image tags. Sorry. :(

Oh and thank you, I aim to please. :)

27.07.09 21:36:43

Sorry forgot. :P

You shouldn’t need to upload all the images again though. The Attached Image just asks WP for any images that have been uploaded to the current post ran through the loop. If it has one it is shown. If you have images inserted in posts via img tags after you’ve uploaded them via the WP uploader then TAI should still pull up the image you will just have a duplicate (because of the image you manually inserted).

I hope I’m understanding you correctly.

28.07.09 21:36:49

Hi again
I’m not sure what you mean with “ran through the loop”…?
Almost all images are uploaded and inserted using WP’s built-in uploader (above the text edit field), uploading one image at a time. After clicking Add an image we’ve mainly used the Browser uploader (not the Flash uploader).
Doesn’t fit with your way of doing it/ a mistake we’ve done?
Any way to make the thumbs just appear?
Thanks for having patience with me
Kj

28.07.09 22:21:47

It doesn’t matter if you use the flash uploader or not, it still goes through the same process during upload.

“The Loop” is just a developers term for the section of a template which repeats to show each post. it generally looks like:

while(have_posts()) : the_post();
//some stuff here
endwhile;

As long as the template reference to the attached image is between there somewhere it should show the thumbnails fine. If it isn’t you will got odd things happening such as no thumbs showing or even thumbnails from posts you weren’t expecting.

If you have a link to the website your testing on or you could provide some screenshots via email of the problem your having it would help a lot in troubleshooting it.

04.08.09 18:20:18

Hi there,

I’m using this great plugin in combination with WPTouch so that I can get thumbnails in an iPhone optimized format. They both work great, but my error logs show this:

:P HP Warning: Invalid argument supplied for foreach() . . . /plugins/the-attached-image/the-attached-image.php on line 580″

Which corresponds to this section of the_attached_image.php file:

foreach($attachments as $id => $attachment) :
		$i++;
		if($i == $image_order) :
			$attachment = $attachment;
			break;
		endif;	endforeach;

Any ideas about what would cause this error?

05.08.09 18:31:19

Sorry about not replying, just had to format my computer & I’ve been reinstalling everything. :P

Anyway. I’m not exactly sure what is going on there. Usually that error would mean that $attachments is empty (or isn’t an array), but if that happens it shouldn’t get to that part of the script since $attachments is checked first. You say it is running ok though despite the error? I’ll see what I can find but it’s very strange.

06.08.09 13:38:28

Yeah, other than this error, the plugin is running beautifully . . . .

One bit of information that I forgot to give in my first comment is that I have placed the code


) twice in the wp touch file — once to display thumbnails on the main page and once to display them on categories.

Not sure if this info changes anything, but I thought I’d include it.

Thanks again for getting back to me. Really appreciate it.

06.08.09 13:42:40

The code in my last message didn’t post . . . let me try it again.


                       
06.08.09 13:45:06

Sorry to be repetitive, but the php line of code won’t display . . . .I tried twice and double-checked that I had done it correctly. Not sure why it won’t show up.

06.08.09 18:02:27

Hi again,

I’m not sure why WP truncates the code sometimes. Can you send it to my email addy: pablorobinson[at]gmail[dot]com

I think it’s something to do with the theme I’m using. :?

12.08.09 05:22:57

Please help!

After activating the plug-in, indeed the first image shows in post but the complete gallery thumbnails also show under main (first image)!

Any advice will be appreciated to make only the first image, thanks!

12.08.09 10:20:39

Hi,

That’s really odd. It has never happened during testing so I’m going to assume it is something unique to your blog. The only thing I can think of that would cause that is somewhere on the post/page you have wrote the gallery shortcode [gallery], or your template has it hardcoded into it with do_shortcode('[gallery]'); at some point. Those are the only ways I know to show all of the thumbnails.

Just to be safe though I have just checked through my test blog & there are no problems like that happening.

Sorry if that isn’t much help, but again that’s all the possible problems I can think of. If you still have problems, but can find anything else about the problem it would help alot.

13.08.09 12:45:40

I turned on the Pick Functionality and set it to 1, and that corrected my first issue of no new images showing up, which, now, I deduce, was most likely because if I re-used an image it did not count it as an image from the Uploader, hence, the only way for it to recognize the image is to scan the content for the nth image, which is 1.

Secondly, when I turn on the Pick Functionality, it seems like it now skews the image most so than it did when Pick Functionality is turned off.

I have no leads on this issue yet, but hey, I fixed my first problem, so that’s something right?

13.08.09 13:03:06

Woah! What? lol.

Yeah unfortunately if you re-use an image that is attached to one post in another post it will not count. I haven’t figured out, or rather I don’t think you can, get it to realize that it is actually attached to a post, just not the one you are in. Good idea with switching to nth content image though. ;)

Not sure about the skewing problem though. I’ve had a check through the code & can’t see anything that might be causing it. What exactly do you mean by skewing though?

Edit: I may have just found something, but I can’t test it at the minute. If you want to give it a go here is what I was going to change:

//if image is offsite we try our best to get the image size;
$imagesize = @getimagesize($img_url);
//if not we have to resort to making an empty array to stop PHP taking a fit.
if(!isset($imagesize[0])) {
	$imagesize = array('', '', '', '');
}

change it to this:

//if image is offsite we try our best to get the image size;
$imagesize = @getimagesize($img_url);
//if not we have to resort to making an empty array to stop PHP taking a fit.
if(!isset($imagesize[0])) {
	$imagesize = array(FALSE, FLASE, FLASE, FALSE);
}

Basically I think if getting the image size fails it won’t set the width & height to false (so that the width & height won’t be written in the HTML & browser will autodetect width & height). Instead it writes a blank width & height into the source code (which for some reason doesn’t show in FireFox’s source code viewer). Those FALSE should auto set them to false if getting the size fails.

If that doesn’t work I’m up the creek without a paddle since I can’t find anything else that would cause the images to skew. :?

Oh and welcome back. :D

13.08.09 14:59:18

Thanks for the response. My comment didn’t make any sense because my first comment didn’t actually go through when I hit the submit button. So.. that comment was actually Part 2 of an issue I was having.

The issue was it was using the default image when I re-used an image from the image browser… since the uploader didn’t count it as an attached image, it didn’t see I was using an image at all.

Since you implemented the new feature, I was able to get around this issue by just telling it to use the 1st image in the post… so I am happy it works.

But, yes, when using the 1st image in the post instead of the ‘default’ way to detect images, it is skewing the image, and I think you are right on the money… it is probably not setting the correct demensions. Thanks for looking into this so quickly.

I’ve been neglecting my site for a while, but I am back now! Check it out if you want. I’m glad you still have my link on your site. I was thinking about starting up a wordpress new section on my site where I can suggest my favorite plugins and custom code. So, if I do do that, then I will link back.

Thanks again for the quick reply.
Eric

13.08.09 15:13:11

No problems.

I had a feeling some of the comment had gone missing. We’ve been having a few problems with someone abusing the server recently, so you might have pressed submit just as the server had a glitch. :? We’ve nearly got that sorted though, I’m going round to whoop the guys ass. :P

The odd thing about that is, it shouldn’t have a problem grabbing the image size unless you are linking an external image (via URL) & your server doesn’t allow external URL wrappers via getimagesize(). That’s why the empty array was in there, PHP would error if I didn’t provide an array in the pattern it expected, but I should have wrote FALSE instead of the empty strings in the first place. Didn’t have enought coffee that day methinks. :lol:

If you do link back it would be awesome. I’ve been neglecting Return True a little too, in regards to new tutorials, I just haven’t had any inspiration recently. I’ve also been really busy building other peoples websites, lol.

Again no problem & thanks. :)

19.08.09 13:49:28

I’m hoping you might be able to help me out – I want to insert the PHP code for this plugin manually into a widget in the sidebar.

The reason I want to do it manually, is so that I can use the same argument that refers to the Related post, to retrieve the image from that post, so that I can display the image below the Related Post’s title in the widget ( I am use an plugin called “The Attached Image” to do this).

Is it possible for you to point me towards the code that I can insert into a PHP-enabled text widget please?

19.08.09 13:57:05

The code you would need for that (I’m not sure since I haven’t done it before) would probably be the same as you use for inserting into the template. So something like:

< ?php the_attached_image('parameter=value'); ?>

Should work. I hope that helps. Let me know if that isn’t what you were after & I’ll help as much as possible. ;)

19.08.09 16:24:42

I just updated Wordpress and now this plugin shows the same image on all posts on the homepage.

Any advice? It was great before I did the update.

19.08.09 16:43:55

I’m not sure why it has only shown after the update but it is usually caused by the way the query is carried out. If you are using it for the standard WP loop it should be ok, but if it is a custom built loop then it will probably be due to the way that is made. If it is in the default WP loop or the loop is already one of the new WP_Query ones then drop me another line as there must be some sort of bug I haven’t picked up.

Just to let you know though I have tested it in all versions of WP up to 2.8.4 and it seems to be working great.

20.08.09 08:22:52

Hi again – is there a way to feed a specific post ID into this code

I have a separate plugin that generates an array of Post IDs and Titles using this code and since I am an amateur PHP coder, I have no idea how to list each of these posts with the title, followed by the attached image. Any clues would be greatly appreciated!

20.08.09 10:01:53

Well normally you would create a secondary loop to get the extra posts using the parameters provided by WP to limit them to what you want. You can find more about the parameters for custom loops here at WP as their docs are more detailed than I could be in this space. To make a custom loop use this bit of PHP:

$my_query = new WP_Query('parameter=value');
while($my_query->have_posts) : $my_query->the_post();
    the_attached_image('parameters=values', $my_query);
endwhile;

That would allow you to get the array of posts, etc in a way that you could pass to the function. I’m not sure if there is a way to pass the array you have though, since WP requires that the value you give the plugin (due to the functions it uses) is an object set up like WP’s WP_Query object.

Sorry if that isn’t any help. :(

20.08.09 20:00:06

I like this plug-in, but I’m running into a problem with multiple invocations of it.

On the index.php and other similar pages (ex: search.php), the medium image size is fine, but I’m trying to use the Full image size for posts.

I’ve tried resetting the query, but it doesn’t seem to work. The medium size still applies to the post.

Any help is appreciated.

Thanks,
SB

20.08.09 20:11:07

I tried re-using some old code for another project which needed multiple invocations. Surprise, surprise, Wordpress developers killed the functionality and failed to replace it with an included feature.

This doesn’t work in 2.8, but it did work in 2.3:

20.08.09 20:57:50

Hey sean,

could you send the code via email to pablorobinson[at]gmail[dot]com as code won’t render properly in the comments because of the theme I’m using. I’m getting ready for a redesign soon which should hopefully sort out that problem.

Again if you send the code to my email I’ll help as soon as I can. Thanks. :)

23.08.09 19:50:29

Righteo, I finally worked out how my related posts plugin works. I can access each of the related posts IDs using the following bit of PHP code.

Now, how do I incorporate this code into The Attached Image code, so that I can display an image for each related post? Thanks in advance, you are always so helpful!

24.08.09 11:04:08

Hi Jake,

Wordpress is being a pain again & has completely removed the code you included with your comment, if you can send it to me in an email to pablorobinson[at]gmail[dot]com I’ll help you asap.

I’ve no idea why WP keeps doing that but I think it’s something to do with the theme, it’s a good job the site is due for a redesign soon. ;)

26.08.09 20:25:39

Can you modify the in_post_image to respect the echo=false attribute.

//...
if($in_post_image != false) {
  // ....
        if($echo === true || $echo == 'true'){ //Echo it?
		echo $image_output;
		return true;
	}else //Ok we'll return it instead.
		return $image_output;
}
//....
26.08.09 21:25:47

That has been fixed now. The update should be available from the wordpress plugin repository in a few minutes. ;)

27.08.09 13:46:26

I just thought of a stupid feature for you to consider, and it would be challenging too! So here it goes.

As it is now, for each post, your plugin returns a thumbnail for that given post.

What if, you made it so that it was able to create a master-image file “cache” with all the post thumbnails… so that they would all be stored in one image file which then would be smart enough to create a css sprite style to display the correct image within the image for the post in question.

A CSS sprite uses one bigger image, for example, a big image with a bunch of icons inside it, spaced out every X height. CSS only has to download the image once, thus only one http_request sent to the server. When a thumbnail wants to be used, it goes X pixels down and uses the thumbnail size Y height Z width to pick the area to display.

Im not sure if I explained clearly, infact, im sure I haven’t… but if you just google css image sprite, im sure it will become clear.

The purpose of this functionality would be to only make 1 http_request for all the attach_image thumbnails so that the page loads faster.

I am working on doing this now for my site and thought it would be cool if your plugin had this feature built in.

-Eric

27.08.09 17:26:42

I get what you mean. Similar to how you make no-delay loading CSS rollovers. You make an image with both the standard & over state on & then use CSS to move the background when you hover.

I think the problem with that would be that without a powerful image manipulation program such as imagemagick (which not everyone has) it would destroy most servers trying to make the image. Mainly because GD, the normal image manip prog, doesn’t have a memory limiting function like imagemagick does, so if GD reaches the memory limit on the server it will crash.

Other than that huge problem, lol, it is actually a excellent idea. Don’t worry though I’m going to add it to my list of ideas & keep looking into it. You know how I feel about challenges. :)

Thanks for stopping by again. :) Oh and if you are on twitter feel free to follow. :P

01.09.09 19:07:58

Hi, I have a question.

From the description:

Image Order:
If there isn’t 3 images it will pick the nearest it can get to the 3rd image.

Is there any way to get the plugin to do nothing in this case? just return false.

In my case the plugin duplicates the thumbnails

thanks in advance

01.09.09 19:20:15

Hmmm I’m not sure, I don’t think so due to the way it grabs the nth image. If you just needed it to get a different thumbnail I’d say use custom fields to override the option, but I can’t think of anyway to get it to return false instead. Sorry. :(

I’ll keep looking though to make sure it can’t be done.

03.09.09 17:40:38

Its me again. The first tab on my site, never displays the thumbnail correctly.
Here is the query calls. Is it because there are two loops, does it get confused or something? I can’t think of any other reason behind it not generating the thumbnail.

03.09.09 17:41:32

Ok, well that didnt work. using the pre tags…. hmmm, what should I do to get the loops I am using to you? Ill try to email it to you.

03.09.09 21:19:06

Me again with another feature idea!

When you use the option to use the nth image in the post it uses the full size image. You should write a function to check to see if there is a thumbnail of that image instead of always using the full size image

This is why I turned off using the Nth image in the post because it was adding a lot of size to my loading time.

To code it, I’d say, the attached image dimensions have to be the same as the wordpress thumbnail size.

It would be as easy as doing making an if image/imagefile($width)x(height).png exists, else.

To make it easier for people to resize thumbnails for this requirement, maybe link to Regen Thumbnails plugin:
http://www.viper007bond.com/wordpress-plugins/regenerate-thumbnails/

I use it and it works great if I want to change the thumbnail size.
Hope you consider this :)
Eric

04.09.09 10:47:27

Well I did actually consider that when I first made the get nth image function, but I hit a wall I could never get round.

It might sound stupid, but here is the problem. I can’t find out the width & height. Yep, I know, it’s stupid but I have no way to figure out the width or height since WordPress keeps track of them in it’s database but because the image isn’t attached I can’t get the info from the database. :(

If you can suggest anyway around that problem I’m all ears, I’ve been struggling with it for a month or two now.

Thanks for the suggestion though. :D

Sorry I didn’t answer your other comments, I got your email (as you know) but WP didn’t send me a comment notification for the others for some reason.

04.09.09 16:52:11

I’ll look around to see if I can find the database entry for the thumbnail sizes.

Like I said in the previous post, another option would be to instruct users of your plugin to use the same dimensions as the ones defined in the wordpress media settings, that way you can just pull your height and width numbers and not worry about what wordpress uses.

04.09.09 17:10:11

It may be in wp_options table:

(70,0,’thumbnail_size_w’,'48′,’yes’),(71,0,’thumbnail_size_h’,'48′,’yes’)

check it out :)

05.09.09 09:50:30

The problem is not with the thumb sizes (if crop is on) but with the medium, and large sizes (and the thumb if crop is off). I would need to know the exact sizes that WP used & in the case of proportionate thumbs it works it out it’s self.

I guess I could find the correct options & then try & work out the proportionate sizes myself like WP does, but math gives me a headache, lol. I might have to seek out my sis’ help (she’s good at math). :lol:

Thanks for finding that, I now have somewhere to start from. :)

05.09.09 22:09:21

Wonderful update! This is amazing. Now, even though WP screwed up my posts, and forgot that I attached images to those posts, using the 1st image in the post with the new thumbnail option is awesome! You are the best bro. Keep up the terrific work.

I may pick out something else from your wish list in the coming weeks for your effort.

Thanks again,
Eric

05.09.09 22:18:21

I noticed that its taking the normal image still on some posts even though a thumbnail image exists. Ill try to figure out a pattern of why its only doing it to some of my posts, but again, not sure why yet.

05.09.09 22:29:20

No problem. I’m just glad my plugin is still helping people. :) Thank you if you do purchase something from my wishlist, it’s much appreciated. ;)

I expected some bugs, the whole system to figure out the thumbnail sizes is quite complicated without WP’s help. I’m just glad that you are able to help out with the debugging it makes the whole process so much easier. So thank you so much for all your help with the fixing of bugs.

Let me know what you find, in the mean time I’ll keep looking myself. :)

05.09.09 23:45:04

Just wondering if you were able to find WPs other DB entries for the other sizes? They are all in that wp_options table

06.09.09 00:19:46

yeah they are listed as thumbnail_size_w/h, medium_size_w/h and large_size_w/h. I’ve added in the ability to pick what thumb size in the options page. So far not sure what is causing the problems your having though.

I’m off to bed for now, but I’ll check more tomorrow. ;)

08.09.09 12:27:45

I cannot find any correlation to with the images that are not using the correct (thumbnail) size. I have no idea whatelse to try. I’m going to take a look at your code today and see if I can see anything apparent.

- Eric

08.09.09 12:56:53

Hey there Eric,

I’m not sure what to suggest. :( By not loading the correct size do you mean for example that you said thumbnails but it is loading some of them as large images? Or is it loading the full size instead?

I did have a problem like that when I was developing that part of the code, but I thought I’d fixed it. There must be some sort of a bug, I’ve yet to duplicate it though, so anything you can find in the code would be a great help in fixing it.

Thanks again for all your help with fixing bugs & for supporting the plugin. :)

09.09.09 15:04:46

No problem, Im glad to help.

Let me clarify with what I mean about the issue I am experiencing.

-I am using the Nth image instead of using the attached image
-I am using the 1st image
-the 1st image has a thumbnail in the directory
-some of them use the correct thumbnail image (one that is actually thumbnail sized)
other posts are using the bigger image even though a thumbnail exists (it is scaling it correctly, but this is creating longer load times since it has to process the full image size)

Feel free to go to my site and right click->properties on the thumbnails on the sidebar and youll see some of them are full size some of them use the thumbnail.

The ones that are using the full sized image actually have thumbnails. You can verify this by copyign the image location path for the ones that use the full size and just change the ending to -48×48. instead of 150×150 or whatever it is.

Any more questions, let me know!
Eric

10.09.09 13:40:10

Test version is still working like a charm!

10.09.09 13:41:34

Thanks Eric.

I’m just about to commit the update to SVN now so that everyone else can update. Thanks again for testing. :)

12.09.09 14:14:18

This is a very helpful plugin! Whith this plugin i can create sliders of news with two image sizes more easily. This is realy good!

But i have truble. I’m using WP 2.7 and my post have the first image in medium size. And in my archive page i want to show the itens with the thumb of images. But the plugin is showing the medium size of them. :(

My looping:


          <a href="">

Thank you very much!

12.09.09 14:24:37

Hi Thiago,

Unfortunately WP seems to have this problem (on my site anyway) where it keeps stripping the code people write. I’ve tried & am still trying to fix that so unfortunately as you can see your code was stripped. If you can send it to me in an email I’ll help you as soon as I can.

Sorry again.

12.09.09 14:30:12

I did some tests and find the problem.

If i insert the imagem in medium size the plugin don’t capture the thum size. It only works only when i insert the imagem in full size, but if i do this i’ll have problems with my type post area.

You have the solution for this problem?

Thanks.

12.09.09 14:38:26

Can I assume you are using the In Post Image function & not the normal attached image function then?

If so both I and RogueDeals have been tested the thumb grabbing system & have had no problems with it. I have just checked again (on my testing server) & I can’t find any problems.

Getting the thumbnail via a in post image is entirely guess work by the server so I’m expecting it not to work for a few people. If you can help me with figuring out why it doesn’t work then I’ll at least be able to see if I can tweak the code to work for you.

Can you email me the code you are using to display the image, the filename of the full size, medium & thumb images, and the size you have set for your thumbnails (in the WP media options page).

Thanks.

18.09.09 16:11:07

Yo. Not sure if this is an issue with your plugin yet, but it seems to be injecting itself into my feeds.

#  10
#
# Warning:  Invalid argument supplied for foreach() in /home/content/e/w/i/ewiegand/html/reviews/wp-content/plugins/the-attached-image/the-attached-image.php on line 672
#  http://roguedeals.com/reviews/2009/09/top-10-easy-ways-to-protect-your-pc/
18.09.09 18:07:04

Hey there,

I’ve disabled the RSS feature. It seems to be hugely incompatible & I don’t think it is worth the trouble of trying to get it to work. RSS in WP just doesn’t work like the posts do.

It should fix that error for you. Let me know if there are any more problems. :)

20.09.09 20:19:08

Thanks for the update :) Ill let you know if I find any other bugs

20.09.09 21:01:40

No problem. :)

Thanks again for all the help.

21.09.09 14:23:55

First sorry for my poor english. Your plugin is realy great. I have one question, is there any way to use it outside the loop, because i want to insert the PHP code in one of my plugins, it loads fine, but every time it show the same image. Can I put manual my post id, something like the_attached_image(‘img_size=medium’,post id number). Thanks in advance.

21.09.09 15:35:36

Hi,

Not really due to the nature of the plugin. You might be able to fool it into thinking you are in the loop though by emulating the object WordPress uses in the loop.

This is untested but something like this may work:

$my_query->post->ID = $id; //$id is the id of the post...
//now call the attached image handing it the fake query object
the_attached_image('img_size=medium', $my_query);

It might work, it might not, but it’s worth a shot. Let me know how you get on & I’ll be glad to help you more if I can. ;)

21.09.09 21:40:09

Hi, thanks for the fast answer. Now if I try these method it show diffrent image, but the problem is stil there, on every post same image. I will try to help you with little explain. I want to input function of your plugin to these plugin http://wordpress.org/extend/plugins/wordpress-popular-posts/ – Wordpress Popular Posts. In my header I call his function and it show 6 popular post. The plugin has thumbnail future, but it show thumbnail only if the post has image in it, and cant show the path, his function show the the <img tag, and cant show them medium image. Your plugin is amazing. It simple and powerfull. And I want to implented but I know only little php. I hope if you have time to check it and try to help. Thank you in advance, really!

21.09.09 21:57:28

Oh ok I get what you want now.

I’ve had a quick scan through the WP popular posts plugin & I think I can help you. I can’t test the code as I’m away from my testing server so please excuse any problems or mistakes, if there are any tell me what happens & I’ll try to help you.

Open up the wordpress-popular-posts.php file from the plugin & look for this section of code:

if ($this->options_holder[$summoner]['thumbnail']['show'] ) {
	// let's try to retrieve the first image of the current post
	$img = $this->get_img($wppost->ID);
	if ( (!$img || empty($img)) || !$this->GD ) {
		$thumb = "";
	} else {
		$thumb = "<a href=\"".get_permalink($wppost- rel="nofollow">ID)."\" title=\"". htmlspecialchars(stripslashes($tit)) ."\"><img src=\"". get_bloginfo('url') . "/" . PLUGINDIR . "/wordpress-popular-posts/scripts/timthumb.php?src=". $img[1] ."&amp;h=".$this->options_holder[$summoner]['thumbnail']['height']."&amp;w=".$this->options_holder[$summoner]['thumbnail']['width']."&amp;zc=1\" alt=\"".$wppost->post_title."\" border=\"0\" class=\"wpp-thumbnail\" "."/></a>";
	}

}

If you don’t want the normal image grabbing feature of the plugin just remove everything between the 1st & last lines of that snippet, so you should end up with this:

if ($this->options_holder[$summoner]['thumbnail']['show'] ) {

}

Now add in this code:

if ($this->options_holder[$summoner]['thumbnail']['show'] ) {
	$my_image_query->post->ID = $wppost->ID;
        $thumb = the_attached_image('echo=false', $my_image_query);
}

You will need to leave the option for the popular posts plugin to show a thumbnail switched on as you have just replaced it’s normal function with the attached image instead,if it’s not on the popular posts plugin will just ignore the alteration.

With any luck that should work, again I can’t test it because I’m away from my testing server and I don’t have remote access, but let me know if it works or if it doesn’t what problems you get.

21.09.09 22:21:50

Amazing, it works, brilliant. Thank you, for the great plugin and for the fast support.

21.09.09 22:23:23

No problem. ;) Glad I was able to help.

22.09.09 04:10:38

Hi.
I am using WP 2.8.4
While installing the plugin I’ve got an error:
Fatal error: Cannot redeclare get_alt() (previously declared in /PATH/public_html/worldphotoshots.com/wp-content/themes/wps/functions.php:53) in /PATH/public_html/worldphotoshots.com/wp-content/plugins/the-attached-image/the-attached-image.php on line 800
Anyone have any idea/solution ?

22.09.09 11:15:17

:lol: wow I wasn’t expecting that… Basically one of the functions I’ve used in my plugin is named the same as one used in your themes functions file.

Basically all I can suggest is to do a find & replace on the-attached-image.php looking for get_alt( & replacing it with att_get_alt( yes with the opening braket.

Sorry about that problem, I’ll fix it in the next version by naming all of the functions something unique. If the find & replace doesn’t work let me know & I’ll rush the next version for you. ;)

26.09.09 02:06:31

I’ve renamed my get_alt function and succeed to activate the plugin.
GREAT JOB! Thank you !
BTW is there any way to generate alt and title using a custom string, like: (‘img_size=small&link=image&css_class=thumb_bar&alt=CUSTOM STRING’) ?

26.09.09 12:34:22

You can, but due to the fact that google can be a tricky mistress & some coding limitations you can only do it via custom fields on a post by post basis. If you check out the custom fields section of the post above you can find the key to use. ;)

I wanna say a sorry to everyone in advance, my main computer’s graphics card has just died on me & I’m using a very under-powered laptop so until I get a new graphics card from BFG I might not answer comments as quick as I normally do.

27.09.09 20:07:31

How about an option to force the custom sized thumbnail to maintain aspect ratio so if you put in 150 and 150 for a custom size and the source image is 320×200 it will really output the thumbnail as 150×94 in order to maintain the aspect ratio.

BTW…my site will be live with your plugin in a week or less but you can see it right now at http://www.gadgetnutz.com / wordpress / (remove spaces before linking yourself to the site.

27.09.09 21:22:50

Very nice site there. :)

I’ll try and add that in as soon as I can, but as I mentioned my computer with my local server on it failed (graphics card). I’ve sent off my card for replacement & I should get a new one in a few days or so.

28.09.09 21:45:21

Hey, I just started getting, this error when trying to upload.

Warning: imagecreatefromstring() [function.imagecreatefromstring]: gd-jpeg: JPEG library reports unrecoverable error: in /homepages/46/d89996492/htdocs/portfolio/wp-admin/includes/image.php on line 147

any thoughts?? I am on a MAC but will try a PC next

29.09.09 12:26:06

Hi there,

that error is produced by GD as createimagefromstring() is a function used by GD to create a new image. GD is used by WordPress to create thumbnails during upload.

Nothing to do with The Attached Image since it doesn’t use any of GD’s functions. I’m guessing from the error that the Jpg (Jpeg) that you are trying to upload is somehow corrupt, have you tried uploading another image?

Here are a few fixes I’ve found for that issue with WP. First is about the way your host handles uploads with php5 (if it uses php5). Add this to your .htaccess file:

AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php

Another suggestion is that you jpg may have been saved with progressive switched on & some people have reported problems with uploading progressive saved jpgs.

Hope some of that helps.

29.09.09 13:37:56

Okay, Progressive was turned on. I will take a look and see if that is it. Where is the .htaccess file? and where do I ad the code, to the top of the page?

Thanks for getting back to me!

29.09.09 13:40:38

Yep that was it. Thanks again!

29.09.09 13:41:58

.htaccess is a file used by WordPress (if you have fancy permalinks turned on) which allows it to change the URL’s to something nice while still going to the correct page. It also allows you to change things that your server does.

Your .htaccess file is generally located in the same place as the wp-admin, wp-content & wp-includes. It is a protected & hidden file though so you will need to be connected through SFTP & not FTP or you won’t be able to see it. Add that code to the top & it might help.

Hopefully the progressive trick will work though. ;)

29.09.09 13:43:57

:lol: No problem. I replied before you added that extra comment. Just ignore it, I’ll leave it on though as it might help someone else. ;)

01.10.09 11:50:42

Hi
First of all: great plugin!!

At the bottom of my posts, the first image of every post in that categorys posts was shown.
But when I upgraded to WP 2.8.4 the plugin malfunctioned. Now the plugin shows the actual posts first image all over the place, so to say.

Here you can see what I mean: http://www.konstfack2009.se/bachelor/baia/elin-t-carlsten/

This is the code I use:


term_id);
if(count($posts) > 1) {
?>

<h1 class="rubrik_lowcase" title="name; ?>">name; ?>

<a href="" title="">


If you could help me out, I would be grateful.

01.10.09 11:52:49

Sorry about that. Here’s the code. I hope…

	term_id);
		if(count($posts) &gt; 1) {
	?&gt;

&lt;h1 class=&quot;rubrik_lowcase&quot; title=&quot;name; ?&gt;"&gt;name; ?&gt;

&lt;a href=&quot;" title=""&gt;</a>
01.10.09 15:09:21

Hi again,
I mailed the code to you…

An interesting thing is that the attached images are correctly shown on an archive page;
http://www.konstfack2009.se/master/

But not on a post page; http://www.konstfack2009.se/bachelor/baia/elin-t-carlsten/

Thanks!

01.10.09 16:35:25

Hi Ivar,

I was hoping I’d fixed the problem with posting code in the comments. :( Apparently not.

I got your code & once again I’m not exactly sure why the upgrade caused the problem but I do know (I think) how to fix it. I’ve got some plans to stop this from happening but I can’t try them until I get my computer back & working. Until then here is how to fix it.

In you code you have this line:

foreach($posts as $post) :

You need to write this:

foreach($posts as $post) :
$my_query->post->ID = $post->ID;

Then change your attached image call to this:

the_attached_image('', $my_query);

That should work.

Again I’ll try & stop this from happening in the first place but until I get a replacement graphics card (which is taking it’s sweet time) I can’t. :(

02.10.09 07:58:27

Happiness!
It works like a charm. I’m very grateful.

One more thing that I had to fix was to add “&orderby=title&order=asc” to the “get_posts” line, because the post order was altered after the upgrade to 2.8.4.

Again, thank you very much!!

02.10.09 09:37:00

Yay. :) Glad it helped.

Yeah some things changed in WordPress recently to do with querying posts so that’s why you would need to add those too. :)

11.10.09 07:08:58

im having an issue with the install, im getting an error “The plugin does not have a valid header.” any help would be appreciated.

11.10.09 10:55:24

Hi,

I’m not sure. I’ve never ever heard of that error before. Apparently though it is due to plugins not having the correct version in their “tested up to:” field in the readme.txt. Problem is mine is already set to 2.8.4 which is the latest version. :(

You could try editing it & changing it to 2.8 but I’m not sure if that will make any difference. Is anyone else having this problem too?

11.10.09 19:00:56

Okay, I got it to install and activate! What Im trying to do now is replace the calendar date Icons in WPTouch plugin to the thumbnails in each post using The Attached Image. Any idea of how it can do that? I read about it here http://support.bravenewcode.com/topic/possible-to-change-calendar-images , but was unable to get it to work, was hoping u could help

11.10.09 20:05:57

The method used in the forum you posted is the only way I’m aware of. I’m unable to test or make sure that it works due to not having an iphone or ipod touch.

I’ll be getting a ipod touch 3G for xmas so I’ll be starting to make sure the plugin is compatible with WPTouch around then.

11.10.09 22:19:31

thanks paul, ill keep trying

11.10.09 22:41:07

Sorry I couldn’t be more help. If you don’t get it working check back in a month or so when I should have my ipod (early xmas present I know) & hopefully will have sorted out how to get it working properly.

13.10.09 23:00:45

Hi,
I try to use the_attached_image() with a custom query in the sidebar.php of my template.
The custom query loop gives me the right posts (I checked by using a ).
But the_attached_image() does not output anything. I’m using wordpress 2.8.4.
I’d be glad if you could give some advice where to look next.

13.10.09 23:17:49

Hmmm, the only thing I can think of is make sure you are handing the query object as a second parameter to the attached image & also make sure there are images attached to the posts.

It’s most likely that the custom query is correct but you must give the object to the plugin as the second parameter (I will be fixing that in the next version so it does it all automatically).

17.10.09 21:01:28

Hey Paul, thanks for your time and effort on this plug-in.

I’m having one small problem. I made a custom page template for a page to display posts from a category. Instead of showing the given posts first image, it’s instead showing the current image of the current page. It can be seen at http://eurofx.thefra.me/news

Any help would be appreciated.

17.10.09 21:12:51

Hi,

No problem about the plugin. If you could post the code you are using to display the posts from a category I should be able to help. ;)

17.10.09 21:36:57

Wow you’re quick!

http://pastebin.com/m72678dbd

*The CSS is going to be replaced, as it currently reflects styling for the sidebar.

17.10.09 21:46:21

Ahhh yes, with my graphics card going off, and taking so long to be replaced I just haven’t had the time to fix this problem yet. I promise to get to it very soon. In the mean time here is a quick fix.

As long as $post is an object, it should be, just give it to the attached image call as a second parameter. Like this the_attached_image('', $post);.

Should work, if not let me know & I’ll see if I can come up with something else. ;)

22.10.09 23:46:17

Thanks. Also thanks for any donations you can make. It all goes towards helping development continue. :)

23.10.09 04:35:12

Thanks for the plugin, it works great!! I was wondering if there is a way to put an image description or caption under the image?

23.10.09 14:07:29

Hmmm. Unfortunately not, but I’m currently considering overhauling the plugin slightly as WP 2.9 has a built in function similar to the attached image meaning I’ll need to add something different to it to make it stand out.

A caption could be a good one, so it’s added to the list. ;)

31.10.09 06:08:56

thanks a lot for the plugin.. it is wonderful..
i would love to donate.. but will wait till i get some $ in my paypal

[...] The Attached Image [...]

17.11.09 18:13:54

This is an awesome plugin! I had a hard time getting pictures to display exactly how I wanted until I found this plugin. Discovered it as I was looking for a solution to my picture problem. THANKS!

Josh

17.11.09 18:29:21

Not a problem. The plugin is currently undergoing it’s version 2.7 overhaul which I’m hoping will make it even better. Glad you found it’s current version so useful though. :)

19.11.09 19:20:14

css_class option: from which .css is reading?

I used with a template css class but no success…

19.11.09 19:58:20

I am working on a website that is new to me. It uses the Attached Image plugin to nice effect. Except now, the client wants to put a flash banner on the home page. I can use a custom field and kimili plugin to get the flash banner in place (instead of the static images used on all the other pages), and all works well. Except the attached image is still trying to do its work, and there are some extra code snippets in gray just below the banner. Here is an example, placed on a low traffic page, I really want the flash banner on the home page.

http://siciclando.com/policies

So, is there a way to turn off attached image on a specific page, or another way for me to get rid of the pesky extra code?

Thanks for the plugin and thanks for your time.

mark

19.11.09 22:55:34

css_class just applies whatever class you provide as the class in the img tag. It has no specific target to any CSS file. As far as I am aware it still works, just check to see if the css class you provide is being written into the img tag if it is then it is just waiting to be provided some styling to that class. What CSS file you put it in is entirely up to you.

19.11.09 23:02:36

Hey there Mark,

Not entirely sure what’s going on there. Have you uploaded the banner as an attachment to that page? It looks as if WordPress is trying to load a flash embed which if the Attached Image picks up as an attached file it will try to load into a img tag (hence the brokenness). I need to make the Attached Image distinguish picture from swf’s, movies etc which is planned for the next version.

The best way to have the flash on the front page (if you only want it on the front) & keep the attached image everywhere else is to open up the template & use a conditional tag. It could look something like this.

if(is_home()) {
  //Do whatever it is I want to happen on front page
} else {
  the_attached_image('option=value&option=value');
}

There you have it. If you put your flash embed in the first condition it will show on the front page & the attached image will work on all the others.

Wasn’t sure how much knowledge of HTML & PHP you have so sorry if I’m assuming too much or if I’ve explained too much. Just shout if you have any more questions. ;)

20.11.09 00:31:49

Hi Paul,

Nice plugin. But i face a very sad problem for a non-coder. My theme doesn’t use the loop, neither the query post function in the way you presented it in your documentation. Here is the way to call posts in my theme :
So, every post displays the same image, the one used in the first post displayed on the homepage. Any simple way to use “attached image” with that code ? Thanks.

20.11.09 00:34:58

The lang tag doesn’t seem to have saved my code section so i try again…

Hi Paul,

Nice plugin. But i face a very sad problem for a non-coder. My theme doesn’t use the loop, neither the query post function in the way you presented it in your documentation. Here is the way to call posts in my theme : global $post; $myposts = get_posts(‘numberposts=1′); foreach($myposts as $post) : setup_postdata($post);
So, every post displays the same image, the one used in the first post displayed on the homepage. Any simple way to use “attached image” with that code ? Thanks.

20.11.09 01:06:01

Sorry about the code not posting I’ve no idea what causes it.

Anyway onto your question. You can use the attached image with that setup it just takes a little bit of extra code. Before the line setup_postdata($post); put this:

$my_query->ID = $post->ID;

then in the call to the attached image add $my_query as a second parameter. Like this the_attached_image('', $my_query);. Hopefully that will work, it just fools the_attached_image into thinking it is inside a WordPress loop.

Hope it works, let me know if you have any more problems. ;)

20.11.09 14:16:41

Thanks for your quick answer. I’ll try this and post the result here …

20.11.09 16:39:49

Hi

First off the plugin is great.

I’ve got a very peculiar problem at the moment on a site.

I have a list of posts on the home page, all from the same category. When I add a post sometimes is doesnt show the Thumbnail at all (perhaps 50 or 60% of the posts), no source code inserted, almost like the plugin doesnt find an image.

If I delete the image from the post and simply re-insert it it shows up. I’ve just hit one now however that wont show at all.

Any thoughts?

Thanks

Lee

20.11.09 16:42:40

Just another detail, this very stubborn post is a copy of another one, no change to the code at all, just copied the content from html view and pasted it back in.

I’ve tried several images that are working fine on other posts so its not an image issue

Hope you can help

Thanks

Lee

20.11.09 17:24:01

Sorry, doesn’t seem to work. Here is the code. Any mistake or misunderstanding about the place of $my_query->ID = $post->ID; ?

++++ global $post; $myposts = get_posts(‘numberposts=5&offset=1′); foreach($myposts as $post) : $my_query->ID = $post->ID; setup_postdata($post); ++

++++ the_attached_image(”, $my_query); ++<?php the_content(); ++

20.11.09 17:45:26

Mmmm! That should work. May seem like a stupid question (but I have to ask) you have put all of this code in php tags? It’s just that the code you have posted opens the tag after the call to the attached image (I’m assuming that’s just how it copied across though).

Actually I may have found something, try moving the line to after setup_postdata($post); that may get it too work. Let me know how it goes.

20.11.09 17:46:16

OK

I’ve just discovered that clicking Pick

Functionality Turn On In Post Image Functionality

and putting 1 as the value fixes this problem

Very odd

I also compared the source code from one that didnt work to one that did and they were exactly the same. Very odd

Thanks

Lee

20.11.09 17:49:23

I’ve never come across that exact problem before but my best guess would be it has something to do with how the loop is configured (or created) in the theme you are using.

Also since you’ve said that the in post functionallity works (that takes the first image from the post content) that would mean it would be your WP loop. The only way I can try to help you is if you post how your theme makes the loop. As it’s probably a fairly large piece of code you may want to paste it into pastebin.com & post the link. If you can do that I’ll help you as much as I can. ;)

20.11.09 18:13:00

Hi

Unfortunately the last option kills the Featured Content Gallery when enabled

The strange thing with this is that it works perfectly on some posts and not others, and as I mentioned its copied and pasted so cannot be an image or post content problem.

You can see the problem on the right column here

http://www.yorkshiremanrestaurant.co.uk/

I can the and find you the loop later

Do you have any thoughts on why the post function would break FCG?

Thanks

Lee

20.11.09 18:18:53

This loop is in category posts plugin, I’ve tweaked it slightly and posted the code on pastebin but I have the same problem whereever it appears (even with a slightly different query)

http://pastebin.com/m3128cf2e

Thanks

Lee

20.11.09 18:34:23

Wow! I’m afraid I’m officially stumped. From looking at the pastebin I can’t see any problems it looks perfect. I was going to ask if you’d made sure an image is attached but you’ve already said you have tried reuploading again & again.

The images that wouldn’t show up till re-uploaded? My best guess is that for whatever reason they weren’t in WP’s db properly or not set with the correct status maybe? As for this stubborn one, I honestly have no idea. You’ve added in the attached image in the plugin exactly like I would have. I just don’t understand how it can work for most of them & not for this one. :(

If you can find out anything else that would help alot, I’ll keep looking over the pastebin & try and find any quirks in the code.

Sorry for the problems your having.

20.11.09 18:50:47

Its not just one stubborn one now, another is doing it, again a repeat of another post, but I’ve tried doing it from scratch and it still wont do it, as I say its also doing it outside the cat-posts plugin.

Do you have any thoughts on why the function option would break the featured content gallery? that just goes blank when its on

Dont worry, its the joys of WP! I’ve already told studiopress (theme people) about adding your plugin, its a damn site better than manually adding links to all the images in custom fields.

Thanks

Lee

20.11.09 18:58:02

Thanks, I always loved Studiopress’ these but thought they should have either used or built something like my plugin, of course that way way back before I made the plugin & they weren’t called Studiopress, lol.

I’m not sure what is causing it to miss things inside or outside of the plugin. The only thing that has ever caused it to drop thumbs is because of different loop types, I’ve tried my best to cover them all but sometimes one I’ve never seen before pops up, the plugin should work with, WP_Query loops & the standard WP loop, I’m currently upgrading it so that it will work with loops that alter the $post variable directly. Other than that I can’t think of anything.

As for the in post functionality breaking the FCG plugin, I’ve never used them together so I’d never notice. I can’t think of any reason for it to break it though as the attached image is dormant until called via the_attached_image() even with the in post function enabled. I’ll have a check through the code, etc but nothing springs to mind. :(

20.11.09 19:16:26

I’m fairly new to WP so if you can tell me where the loop is likely to be in the code I grab it for you to look at

I’m heading out now so will be tomorrow when I’m back on it

Lee

20.11.09 19:21:16

The loop generally looks like this:

if(have_posts()) :
  while(have_posts()) :
    //Stuff here
  endwhile;
endif;

Something like that, I’ll need the few lines above it too.

21.11.09 02:46:39

Which file will it be in??

I know meh PHP but WP is sodding infuriating at times!

Lee

21.11.09 03:23:00

You can find the all index page of the theme here : http://www.buffet-traiteur.fr/index.txt
Line 59 for the first change of code.
The plugin was activated during the test, of course, and there was an image in the post.

21.11.09 03:24:34

Sorry, didn’t see :
“Actually I may have found something, try moving the line to after setup_postdata($post); that may get it too work. Let me know how it goes.”

I try that.

21.11.09 03:32:55

Doesn’t work either when moving my_query after setup_postdata.
Theme file here : http://www.buffet-traiteur.fr/index2.txt
Sorry … ;)

21.11.09 11:33:44

It depends, it’s in quite a few of WordPress’ files, single.php, category.php, index.php, archive.php any of them. They all relate to a different part of WordPress. You might want to read a bit of the WordPress codex first as Theme Development is tricky if you don’t use the codex.

21.11.09 11:41:59

I don’t know what it is with me lately. I’ve miss the obvious problem with the code I gave you. It should say this:

$my_query->post->ID = $post->ID;

You’ll have to try it before & after setup_postdata($data); as I can’t remember which place it should go.

Again I’m sorry about the problem that should fix it. ;)

21.11.09 12:06:28

This is index.php, it shows individual posts without any fluff on

http://pastebin.com/m610b17f9

Lee

21.11.09 12:10:31

Heres sidebar.php

If you can see anything it would be a big help!

As you said I dont understand why it interferes with FCG, not as if theres any JS involved

Lee

21.11.09 14:09:56

I can’t see anything that would cause a problem, the loop is just a standard WP loop, in the index.php anyway, as for sidebar.php I don’t know because I can’t see a link to a pastebin, lol. WP can be a pain sometimes so sorry if it stripped it. If you post it again I’ll have a look.

21.11.09 14:49:31

I forgot to paste the link

http://pastebin.com/m1cfe96ec

But it cant be that any really as it fails in the main body featured items also.

Bloody odd this

Lee

21.11.09 15:23:52

Paul

Sorry about this, I’ve switched the function setting again and the FCG is working fine, I suspect that was a java glitch or something as it seems fine now and the thumbnails work perfectly now with that setting on.

Thanks for you help, hopefully its going to be fine now. I’ll try and send you something over

Thanks

Lee

21.11.09 16:37:50

No problems. I’ll keep looking a little longer for the cause of the thumbnail problems just in case there is a bug somewhere. As for what happened to FCG, your guess is as good as mine when it comes to JS. :lol:

Thanks. ;)

25.11.09 14:17:58

I have a problem with
get_posts(‘offset=0&numberposts=6&category_name=homepage’);
foreach($myposts as $post): setup_postdata($post);
the_attached_image(‘img_size=thumb’);
endforeach;

I’ve inserted this
$my_query->post->ID = $post->ID;

Like:
get_posts(‘offset=0&numberposts=6&category_name=homepage’);
foreach($myposts as $post): setup_postdata($post);
$my_query->post->ID = $post->ID;
the_attached_image(‘img_size=thumb’);
endforeach;

But it does show the first thumb with every post. Can you help me?

25.11.09 15:12:30

You need to provide the $my_query variable as the second parameter to the attached image. Like this:

foreach($myposts as $post): setup_postdata($post);
  $my_query->post->ID = $post->ID;
  the_attached_image('img_size=thumb', $my_query);
endforeach;

It’s a problem with the way I implemented post looping due to a bug in WP 2.7 & never fixed it. I’m fixing it in the new version so you won’t need to do that soon. Hope that helps. :)

25.11.09 18:31:32

I’ve tried this:

foreach($myposts as $post): setup_postdata($post);
$my_query->post->ID = $post->ID;
the_attached_image('img_size=thumb', $my_query);

With no result… no image is shown…so I tried this:

foreach($myposts as $post): setup_postdata($post);
$my_query->post->ID = $myposts ->ID;
the_attached_image('img_size=thumb', $my_query);

It seems to work… but every post in de for each loop is containing the same image(first post is having a image, te other posts don’t have a image) I hope you’ll understand it with my poor english

25.11.09 18:46:49

I’m not sure what’s going on there. I’ll try to replicate the code you have on my local server & see if I can come up with anything. I’ll get back to you tomorrow if that’s ok.

Sorry about the problems.

26.11.09 22:28:09

Sorry it took so long to get back to you. I’ve tried this code & it seems to work ok on my local server:

$myposts = get_posts('offset=0&numberposts=6');
foreach($myposts as $post):
  setup_postdata($post);
  $my_query->post->ID = $post->ID;
  the_attached_image('img_size=thumb', $my_query);
endforeach;

If that doesn’t work it must be something unique to your setup which is exceptionally hard for me to help you with. :( Sorry.

[...] install The Attached Images plugins properly. Secondly, paste the code (given below) before the <?php the_content(); [...]

03.12.09 04:34:46

I’m totally confused as to how to get this plugin to work… What file do I edit… and where in the file do I put your recommended text?

Thx for your help.

03.12.09 16:46:43

Hi,

You have to edit your WordPress template file for the area you want the picture to show. For example, if you want it to show the picture on your home page find the index.php file in your template, find the loop, and add the_attached_image() in the loop.

03.12.09 16:53:54

Thanks so much this is a really great plugin. I’d say it would be even greater if you could use multiple template tags to pull say first image 1 in the gallery order and display it large and then another to display image 2 medium sized etc.

Custom fields get a bit laborious when it comes to that kind of setup.

Thanks for all your hard work and contribution to help make our lives easier with this great plugin!

03.12.09 17:15:14

Hi,

Thanks for the support. :) I think you may be able to do what you asked. I’m not sure if I added the feature yet (I don’t have access to my dev version at the minute) but if you add the_attached_image('img_size=large'); for the first one and the add the_attached_image('img_size=medium&image_order=2'); it should show the first image large & then the second image medium. If you don’t have a (n)th (second in this case) image it will show the nearest it can get to the (n)th image.

I hope that makes sense, let me know if that works & I agree about custom fields they are a pain sometimes. ;)

11.12.09 04:26:20

Hallo,

Great plugin! It’s the second time I used it in a blog.

Though this time, I was wondering if it will be possible to add a style effect to the thumbnail when you have the mouse over (a:hover)?

I tried a few things like:
.class a:hover { xxx }
.class img:hover { xxx }

But none worked. Any ideas? or maybe not possible?

Thanks!

12.12.09 03:15:11

Really really sorry about not replying sooner.

As for your CSS it looks fine to me. I’ve built a few websites using my plugin with a hover effect on them & I generally gust use the psudo hover. Althought :hover will only work on the a tag in IE6. If that’s not the problem (which I’m guessing it’s not) then I’m not sure.

If you can provide any more info that might help I’ll certainly take another look for you. Sorry I haven’t been much help. :(

14.12.09 01:03:07

mhmh did my last comment go through?

14.12.09 01:09:56

I guess not. ahh here we go again.

Just wanted to say thanks!! And also for creating such a useful plugin.

No worries you didn’t answer right away. As long as you answer at some point, all is good. Plus it’s the weekend and the holidays =)

I appreciate your answer, as when I heard you have already tried the hover effect in some of the websites you’ve done with this plugin, I tried once again. But something different. I stopped calling the image or link in the class.

And it worked!
Here’s the code that worked out for the hover effect in the thumbnail:
.class:hover { xxx }

You can see it working in my website’s blog:
http://tinyurl.com/yaj6og6

Cheers!

14.12.09 04:17:13

Hi, thanks for understanding about the late reply.

Good job on getting it sorted, I don’t know if you’re aware but .class:hover will not work in IE6. Don’t quote me on that as my cross browser compatibility is a little rusty, but I’m pretty sure IE6 doesn’t recognise psudo operators in anything but the a tag.

If you don’t care about IE6 though then you’re all set. :)

14.12.09 13:42:39

Just another little message, now that I’ve had a proper look at your site (which is looking good by the way).

If you aren’t really bothered about IE6 then feel free to ignore. Your pseudo (.class:hover) will not work in IE6, which I’ve already mentioned, but also the semi-transparency will not work as IE6 doesn’t understand opacity: 0.5 in CSS.

Sorry if it seems like I’m going on, and on, but I just want to let you know that some of your viewers may not see what you expect if they are using IE6 (which unfortunately is still quite a popular browser).

14.12.09 15:59:33

Hey thanks again for your feedback! And for taking the time to look into my website.

I actually do not care if people using IE6 can’t see the hover effect in my thumbnails. If they are using IE6 though, it’s already sad for them anyway.

I honestly don’t understand how so much people uses IE, when Firefox is just a better browser.

And actually, I do tested my website in IE anyway, as I know many people still uses this horrible browser. And I don’t know about IE6, but in IE7 it works.

I hope at least people with IE, is using the current version 7.
Because there you can see the hover effect (.class:hover) working just fine as in other browsers.

About the opacity. That one works fine too in IE7 (at least). There’s a little trick on the code for IE css opacity: (filter:alpha(opacity=50)).

Cheers!

14.12.09 16:14:24

Yeah, most things work in IE7 (thank god) although it’s still an awful browser. I loath IE in all incarnations although if I had to pick IE8 is the best.

From what I can find out 11.1% of people use IE6, which is a lot lower than I thought, so I’m glad to see it’s dying out.

Glad to hear designers & developers are finally deciding to drop support for it too. :)

[...] my website for more information on what each option does, or click documentation in the options page for full [...]

16.12.09 15:17:20

Can anyone please explain me how to use the ‘att_custom_img’ key?
I would like to insert an image from the media library. The name of the image is ‘adv_ace’.
I’m trying to get the url by the following code, but it doesn’t work:
the_attached_image('img_size=large&att_custom_img=adv_ace');

Is it also possible to use a custom field from the post ‘advertorialImage’ that has the value ‘adv_ace’ ?

Please help

16.12.09 15:35:29

Hey Arnoud,

The att_custom_img is the key for the custom field in a post, not for the legacy attributes as you have used it. There is no attribute support for the custom image. It wouldn’t really make sense to include it as it would set it to permanently show the custom image completely defeating the purpose of the plugin.

You can however use att_custom_img in the custom field keys on a post by post basis. You must also supply it with the ID of the attachment, not the name of the image. To find the ID go to the media library and hover over the images link, and check your browsers status bar for the ID, it looks like attachment_id=1234.

If you do just want to have that image show permanently you can use a native WordPress function wp_get_attachment_url(); instead. Just give it the same ID as I told you to find before & it will generate a URL to the image file.

Hope that helps.

17.12.09 11:53:45

Hello Paul,

Thanks a lot for the explanation! I’m using the wp_get_attachment_url(); you provided now. In the post custom meta fields I’ve assigned the attachment ID that I want to use (I understand the attachment NAME can not be used?), and that works! :)
I’m also using the_attached_image though to show the first image as a thumbnail in the archives. Great plugin!

27.12.09 14:53:12

Fantastic plug-in!! Thank you very much for sharing!!

Anyway, how do I get returned output from fancy custom field with key att_in_post_image? I’ve tried setting the ‘Echo or Return’ option to ‘return’, tried using the_attached_image(‘echo=false’), tried turning on ‘In Post Image Functionality’… but none of those works. It always echoed the output.

Also, it seems that when I turn on ‘In Post Image Functionality’, only the posts with in-post images get detected, those with attached images aren’t showing. Can it automatically detect whether I have in-post, attached, or custom, then output accordingly? Because I use attached images for some posts, in-post for others, and custom (att_custom_img) for some others as well.

Could you enlighten me on these issues? Or maybe implement these features if they’re not there already?

Cheers! Keep up the good work!

27.12.09 15:12:22

I’m sorry… what I meant to say was getting the URL only (not a returned output, as I said above)… How do I get the URL only for att_in_post_image?

Btw, I’ve set ‘att_img_tag’ to FALSE too… and still it displays the IMG tag…

Can you help?

Thanks!!!

27.12.09 16:41:21

Hey there,

Sorry I haven’t replied sooner, been busy with Xmas & my site has been getting alot of attention from hackers recently so I’ve been making sure all security holes are fixed.

It seems there is a problem with in post images & turning off the image tag generation, I’ll get try and get that fixed asap. As for attached images, and in post images. The back end admin is global, whatever is set there will effect everything, if you want to override that you have to use a custom field, or a template call. The heirarchy is as follows: custom field > template call > admin.

I hope that makes sense. Again I’ll get the image tag generation fixed as soon as I can, so look out for the update via the plugin update page in WordPress.

27.12.09 16:50:55

I’ve updated the plugin. Turns out I forgot to add the check for whether or not to generate the image tag in the in post function. That’s what you get for coding without enough coffee. :lol:

Let me know if you have any other problems. ;)

30.01.10 06:05:02

Gracias por postearlo lo andaba buscando.

30.01.10 10:35:55

No problems. ;)

03.02.10 00:26:30

Thanks so much for developing this. It’s pretty simple to use particularly for the newbie like me. I also have a very simple question but I can’t figure out how to do it. How can I center align the image so in each of the excerpt? I tried playing with the css class (which I don’t even know if it’s the right place to do) and nothing’s happened. Could you help me with this?

03.02.10 00:49:04

It generally depends. Centering an image can be done by adding align=”center” to the image tag, but that’s obsolete now. The best way is to use CSS sometimes text-align:center works or margin:auto 0px depending on the situation.

If you are unfarmiliar with CSS you will need to try to learn some basics. It can be difficult but let me know if you have any problems or questions. I won’t be around for a while tomorrow as I’m out all day but I’ll try to get back to you asap should you have any more questions.

03.02.10 02:18:32

Thanks Paul for such a quick reply. I’m still learning the basics bits & bits everyday but it’s not easy :) Anyway, I still couldn’t quite figure out where to place the CSS “text-align:center” to. Do I need to put it in the index.php? Could you pls let me know where speficially?

03.02.10 02:41:32

No worries, learning new things is always difficult at first, I’ve been coding for nearly 13 year and I stll learn new stuff every day. It’s a neverending battle.

Now I’m actually writing this in my iPod touch, while in bed (couldn’t get to sleep lol) so please excuse any messyness. Code isn’t the easiest thing to write on an iPod.

The CSS would go in you themes CSS file normally it’s called style.css but it varies from theme to theme. You would use the CSS option of the attached image to pick a name for your style, something like att_img_center or something. Doesn’t really matter as long as it means something to you and is easy to remember. Next in you CSS file you would need to add a new rule like this:

[/css]
.att_img_center {
text-align: center;
}
[\css]

I hope that helps a little. Again let me know if I can help anymore but it’ll be tomorrow now as I better get some sleep. ;) Good luck.

03.02.10 23:01:51

Thanks again Paul. Sorry for my late response. I think I’m getting there. Still trying to work on it but I think I should be able to do it. I’ll pop you a msg again if I couldn’t but thanks a lot!

03.02.10 23:06:53

Not a problem. It can take a while to learn, but you can do practically anything once you’ve learnt the basics. ;)

Leave Your Response

* Name, Email, Comment are Required

£25.88 / £1200

Help me buy an iMac so I can develop iPhone/iPod apps. If you would like to donate, or you want to learn more about why I started this fund click here.

We're Talking About...