Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am confused about the exact purpose attachment.php ( and image.php) . I notice many themes dont have them. If single.php displays the image the way I want then is it OK to leave it out. On the other hand could i just make a copy of single.php for attachment.php and leave out the sidebar.

The other thing that confuses me is that when I add a gallery to a post I get the option to open images in an attachment page but when I add a single image to a post it only gives me the option to open the image as an image file (outside of the theme - ie without menus etc). I cant understand the point of this. What is the point in having an attachment.php file for images (or an image.php file) if it isn't going to get invoked when someone clicks on an image.

Ideally what i need is a good tutorial on attachments but I cant find any and i can find very little info in the codex.

share|improve this question
    
check this one mdawaffe.wordpress.com/2006/12/05/… –  booota Sep 13 '11 at 13:02
    
looks like it will be helpful, thanks –  byronyasgur Sep 13 '11 at 17:54

1 Answer 1

up vote 1 down vote accepted

This is part of the WordPress template system, it allows you to drill down and further customize output based in the template hierarchy, for instance if you want the attachments to have separate functionality/style then your single.php, you simply create attachment.php or go even further with MIME_type.php (like images).

http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

Also you have 4 url options when inserting single images: custom url, file, post or none

enter image description here

share|improve this answer
    
Thanks,I think i may have missed something.But having looked at it again I think my confusion arises from there being different options available on edit than on insert. You correctly point out the insert options but when editing the options appear as: custom, image, CURRENT or none. Surely this means that the only way to have an existing image open in an attachment page, unless it's url was originally set to 'post' i guess as maybe the 'current' setting retrieves this, is to take it out and put it back in again. Would you agree; or is there a way to work out the post setting for a media. –  byronyasgur Sep 13 '11 at 17:50
    
.... further to this i actually discovered that taking the file extension off the end of the image url ( in my case anyway ) gives the post url which causes the image to open in single, index or the various attachment templates as explained above. I haven't bothered to check what happens when we have image.png, image.jpg etc in the same blog post –  byronyasgur Sep 13 '11 at 17:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.