An attachment is an image or other file uploaded through the post editor's upload utility. Attachments can be displayed on their own 'page' or template. For more information, see Using Image and File Attachments.

learn more… | top users | synonyms

1
vote
1answer
713 views

How to retrieve alt attribute for an attachment (uploaded image)?

I have some IDs of attachments (images, not from current post). How to I get the alt attribute for those images? I have tried to look into wp_get_attachment_image_src and wp_get_attachment_metadata ...
1
vote
1answer
813 views

Add custom field to image editor

How do I add custom field to the image editor, such as under the image 'Description' field? To be much clearer, it's where the settings for the images are after you upload an image in the attachment ...
1
vote
1answer
1k views

media_sideload_image file name?

I'm using media_sideload_image to download images from the web and store them. However, the problem is that the ones from youtube are always called "hqdefault.jpg", which means that it will override ...
1
vote
1answer
687 views

List Post Attachments - Remove Image Thumbnails

I'm using the following code to display a list of the posts attachments within a sidebar: <ul> <?php $args = array( 'post_type' => 'attachment', 'post_parent' => ...
1
vote
2answers
2k views

How to add media from front-end to an existing post?

Golden Apples Design created (as far as I know) the media upload function that many people on WP.A and elsewhere seem to recommend. But all of the Q&As I can find on StackExchange deal with ...
1
vote
1answer
2k views

How do you modify the 'post_parent' of a custom post type?

I want to be able to edit the post_parent of a custom post type. Basically in my use case I want to mimic how WordPress uses attachments: have a custom post type that is sort of a subtype to post or ...
1
vote
2answers
2k views

Post Via Email - How to send Attachments with it (e.g. PDF File or JPEG Image)?

In regards to the 'Post via Email' feature, does anyone know of a way to send an attachment with it? In this case it would be a PDF document.
1
vote
3answers
481 views

get the image of the post

Im running 'the loop' and I want to get the image of the post (in original size - not thumbnail), how do I do it? thank you.
1
vote
1answer
28 views

Show attached media image if no thumbnail image detected

I use the if ( has_post_thumbnail() ){} to check if the post have thumbnail image, but this echo get_attached_media('image', $post->ID); displays the word Array I need to show the ...
1
vote
1answer
768 views

Add an image gallery to a custom post type?

I am pulling data from an external web service into a custom post type. This data includes images. How can I create an image gallery, add some existing attachments to it, and associate it with a post? ...
1
vote
3answers
174 views

Out of memory error reporting

When users upload very large photos and memory is tight, it seems like Wordpress runs out of memory - fails to resize the uploaded photos and does not create the necessary metadata ...
1
vote
1answer
268 views

Show how many images are attached to a post/page on compose page

On the front-end, I'm using a query to show all attachments attached to the current post. However, on the compose page, there's no way for a user to see how many images are attached without opening up ...
1
vote
1answer
3k views

Adding width and height to wp_get_attachment_image_src

I'm trying to add the width and height attributes to the wp_get_attachment_image_src. Why is this returning width and height:0? <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( ...
1
vote
1answer
347 views

Disable edit media attachments?

Looking for a way to disable the "Edit Image" option. I would still like to be able to edit the description, alt, etc. But remove the Edit image button or disable that image editor. Thanks,
1
vote
1answer
87 views

Add a term to an attachment submitted from front end

I have a front end post form where users can upload a file with their post that I save as an attachment using media_handle_sideload(). I need a way to add a term to that attachment so I can show a ...
1
vote
1answer
116 views

media_sideload_image with rewritten urls?

When I try to use media_sideload_image with a path like this http://placekitten.com/300/200, it gives me an error. That is because it don't know the filetype or the filename. Best way to upload the ...
1
vote
1answer
6k views

get images attached to post

I want to have the ability to use pictures from the media library in a jquery slider on the home page so that it's easy for someone else to update the pictures without having to hardcode it. I have ...
1
vote
1answer
83 views

How to manage a big collection of files with wordpress?

I have a collection of nearly 3000 swf files that will be used in some of WP's post. Two options that I can think of-- Upload them to WP Media Library,they'll become attachments, I can query ...
1
vote
1answer
296 views

How to remove parent section from attachment URL?

I have buddypress installed. All URL goes under BP's URL structure. If an attachment belongs to a document in a group, the URL is: http://domain.com/groups/group-name/docs/doc-name/attachment-name ...
1
vote
1answer
721 views

Image still attached to post even after removing it as featured image

I'm sorry if this is too noob of a question, but when I upload an image and set it as the featured image then later remove it (as featured image), the media list still shows it's "Attached to" the ...
1
vote
1answer
1k views

Get post attachment images dimension and use in embed code

I am trying to make things work like where any post attachment image will generate embed code automatically. Example: If I upload and add two images 1. 250x150 2. 600 x 160 and insert into post. Now ...
1
vote
2answers
221 views

How to set a conditional statement for $attachment->post_excerpt, to check for value?

I have a custom function which looks if an attachement has a certain caption value, if so the attachement is selected, like so foreach ($attachments as $attachment) { if ...
1
vote
2answers
681 views

How do I permanently Disable Attachment Post URL

How can I get rid of the attachment URLs completely? I don't want users to have the ability to link an image to the Attachment URL when inserting an image, ever. I've done things in the past like ...
1
vote
3answers
2k views

Add multiple images to a page sidebar

What I am trying to achieve is this: I have a simple page and I want to dynamically add multiple images to it on the sidebar one underneath another. I was thinking about either using meta boxes, post ...
1
vote
1answer
319 views

Get the bare URL for an attachment

I'm trying to get the link to the thumbnail size of an attachment image. I tried this: wp_get_attachment_link( $img_id, 'thumbnail' ); but it returns the actual HTML for the image wrapped in a ...
1
vote
2answers
229 views

custom admin thumbnail for videos, not getting post's id?

In the attachments edit page i'm trying to use the selected thumbnail instead of the default icon. 99% of the way there but i can't get the attachment's id into the function. Am i missing something ...
1
vote
1answer
1k views

Count all images of a certain post type

I followed two posts related to my query. One was about the number of images attached to a post and second about showing all images of a certain post type. I tried to combine the two codes in the ...
1
vote
1answer
2k views

Gel all image from certain post type

I've found similar questions here, however I can't modify the answers to get images only from a certain post type - as the post type in those examples are "attachment" and not the name of a custom ...
1
vote
2answers
1k views

How can I UN-attach media from a post?

I'm having a trouble un-attaching media from a post without deleting it entirely from my site. Is there a simple way to unattach an image from a post for instance?
1
vote
1answer
1k views

Delete post with all files attached to it

On my site I have multiple authors, who can add/edit/delete custom posts and upload (attach) images to those posts. The problem is - when they delete their posts, attachments stay on the server. So, I ...
1
vote
1answer
1k views

How to specify width and height in the_content for image attachments

When the_content print attachment images (attachment template) it automatocally displays the picture. Is there a hook to specify the width and height of the image displayed?
1
vote
2answers
1k views

How can I remove fields in the attachment editor?

Is it possible to remove a default attachment field from the attachment editor, for example the "Caption" field ? To give you some context, I'm trying to build a custom attachment editor page. I ...
1
vote
1answer
592 views

Custom Post Type - List all attachments on Edit Screen

I'm currently building a custom post type in Wordpress and I need to be able to list all attachments inside the edit screen. I know how to do this on the front-end template, but anyone know the code ...
1
vote
1answer
1k views

How to delete orphan attachments?

I've been given the directive to "retire" about 1000 articles from a wordpress site I maintain. Deleting the posts from the DB is trivial, but how would one go about deleting the orphaned files from ...
1
vote
3answers
2k views

Image still linked as attachment to page even though it has been deleted

I have been working on an image gallery feature where I grab images which are attached to pages and display them in various places via the get_posts() function. However, I am finding that when I ...
1
vote
1answer
46 views

How to add a class to the attachment images

When I'm in the Wordpress editor and I add an external image with the 'img' button, my html result wil be like this: <img src="http://example.com/image.jpg" alt="image" /> How can ...
1
vote
1answer
30 views

Password protect media attachment - share across guests

I'd like to show certain content to people with a password, specifically links to media files like this: <?php if($currentuserid == foobar): ?> <a ...
1
vote
1answer
122 views

Replacing all attachment links in post with media file link

I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back ...
1
vote
1answer
179 views

How to get attached file in wordpress from custom post

I am using the Download monitor plugin I am listing the posts by category the following way $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); <?php ...
1
vote
3answers
158 views

File upload, uploads only file name

I am working on a simple front end image upload in Wordpress. With this piece of code I can upload to the wordpress media section but I only upload the name and url of the file then, no image. Does ...
1
vote
1answer
1k views

How to solve: An error occured in the upload

This error message appears when I try to upload any picture. Currently I am using WordPress 3.8.
1
vote
1answer
328 views

Use the WP media uploader dialog for uploading a form attachment (non-admin). Offering progress and drag and drop feedback

I am building a simple contact form (non-admin) that has an attachment field. Of course I can just handle the upload via WP's wp_handle_upload function. However, I would like to give my visitors a ...
1
vote
1answer
996 views

Image Attachment Url Rewrite

I'm having an issue with url rewriting for a theme I'm making, which is basically a gallery theme based on the roots theme. Here's how the site navigation works: Home Page (With Tiled Image Gallery) ...
1
vote
1answer
300 views

Delete all thumbnails for a post

I have a function that sideloads a YouTube thumbnail onto a page... but I want to remove the featured thumb on the page first (and remove all the various auto-generated sizes, too). I'm assuming I ...
1
vote
1answer
360 views

Exclude featured image from attachment loop

For my jigoshop theme I'm able to retrieve the images attached to my product post. However it pulls all images from both the featured image and my metabox images. What I'm trying to do is make it so ...
1
vote
1answer
72 views

Custom attachments styling in post view

I am looking for easy styling list of .doc attachments in post. For example i want to put every in <li></li> tags and do some proper styling. So far I am get my post content this way: ...
1
vote
2answers
3k views

Password protect some uploaded files, so only logged-in users can view them

I would like to protect some uploaded files, so that they are not publicly accessible (they are not accessible without a login). I'm uploading some PDF files, and I'd like to mark some of them as ...
1
vote
2answers
286 views

Image rotation fails to regenerate custom sized thumbnail

I'm using custom image dimensions in functions.php like this: add_image_size( 'custom-size-thumbnail', 120, 120, true ); I uploaded some pictures with wrong orientation, so I used "edit" options to ...
1
vote
1answer
203 views

Display random gallery images and its parent post title leading to parent post permalink

I usually have a gallery in posts. I want to display random image and its post-title from a random published post which can lead to permalink like related posts below a post. I used this code: ...
1
vote
2answers
221 views

Image Gallery Numbers for 3.5

In previous installations of WordPress it was possible to number images in attachment.php using the code below, which was originally provided here. However, I'm finding that this code no longer works ...