WordPress.org

Ready to get started?Download WordPress

Forums

What constitutes an Attachment? Need clarification. (8 posts)

  1. Matt Hill
    Member
    Posted 6 years ago #

    I think I have a serious misunderstanding about what attachments actually are!

    I had thought that attachments were the files you actually INSERTED into your post, but it turns out anything is considered an attachment that you UPLOADED while editing your post. So a file becomes 'attached' the that post if you uploaded it, WHETHER OR NOT you actually then use it in the post by inserting it's code into the editor.

    Can someone please clarify if this is the case and if so, how to get around it?

    If you want to know why I'm asking, it's because I'm using some custom code to pull the FIRST image attachment from a series of posts to make a slideshow. The code was working fine when I only had one image in each post, but when I uploaded some more images to some of the posts, the slideshow started showing those instead, even though I hadn't inserted them into the post editor.

  2. Justin Tadlock
    Member
    Posted 5 years ago #

    Yes, any file uploaded to a post/page becomes an attachment. It's an attachment even if you don't insert it into the post.

    With WP 2.6, you can order the attachments. So, if you want the first image, you can drag it to the top of the list in the media uploader.

  3. billray
    Member
    Posted 5 years ago #

    I'm confused on 2.6.2's media library and the relationship between the attachment_id and the post_id.

    I want the filename/url of the first image attached to a post. I want the file uploaded -- pre crunching by media library. I need to get at the jpeg associated with each post so I thought that getting it by attachment_id would be the best approach.

    I have inserted one image per post from files contained in the media library. The images show up fine in each post, but I've noticed that in the media library sub-panel that the 'appears with' column is often blank.

    So when trying to pull the latest attachment from posts as discussed, I'm not getting an attachment_id returned.

    Any help would be appreciated.

  4. Justin Tadlock
    Member
    Posted 5 years ago #

    I have inserted one image per post from files contained in the media library. The images show up fine in each post, but I've noticed that in the media library sub-panel that the 'appears with' column is often blank.

    Those images aren't attached to your posts; they're only displayed. That's no different than posting an image from Flickr or some other image-hosting service.

    Files that are already in the media library before you post cannot be attached to a new post.

    You must upload that file when writing a new post. That's how it becomes an attachment.

  5. billray
    Member
    Posted 5 years ago #

    Justin/Greenshady,

    Thank you for the clarification. I am trying to use your plugin and the fact that I uploaded some images to the media catalog, then posted got me quite confused.

    So, if again, I want to have basically one image per post and not use gallery what is the best way for me to solve the problem. [I need to get at the full sized jpg file name for additional processing).

    I noticed that in the post html wp puts in the attachment id but I certainly don't want to have to parse the html just to get at the file name.

    Is the parent-post id the way to get at it? Normally everything seems a little easier in WP than this media library stuff.

  6. letheos
    Member
    Posted 5 years ago #

    Is there a plugin or a hack that permits to attach an already uploaded media to a post?

  7. Matt Hill
    Member
    Posted 5 years ago #

    This whole concept of attachments in WP is deeply flawed.

    It's fine at the most basic level if you just use an attachment to be displayed on the post it was uploaded through. But once you start doing anything remotely clever to manipulate attachments, especially manipulating groups of images that were attached through different posts, this relationship causes more problems than it solves.

    I wonder why this approach was used?

  8. Czymra
    Member
    Posted 5 years ago #

    Has there been any progress on this issue? I dearly need the function to attach Media Library Items to a post.

    I did find the Attachment Extender Plugin which is amazing but it doesn't work for 2.6.3 it seem. Any help would be greatly appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic