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
458 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
172 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
261 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
2k 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
84 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
113 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
288 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
681 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
219 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
670 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
1k 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
309 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
228 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
7k views

how to get original image using wp_get_attachment_image_src

I want to get the original image with the same width and height as uploaded. My original image is 630*370. Using the following function call I get a thumbnail sized at 630*198. ...
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
584 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
18 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
79 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
147 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
123 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
893 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
901 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
271 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
312 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
71 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
261 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
191 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
218 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 ...
1
vote
2answers
473 views

How can I attach hotlinked images in posts/pages within the same server?

Not sure if this makes sense but I'm trying to attach hotlinked images to their posts/pages with no lucky, most plugins such Cache images works ok but only to external domains, I need to auto-attach ...
1
vote
1answer
312 views

Multiple images in one attachment page

I want multiple images for one post attachment page, but there is no option for that. How can I do that?
1
vote
1answer
471 views

How to delete all post and attachments of a user when I delete it?

When I delete a user, WordPress can just delete the post or page of this user, not his custom post and his attachments. An idea for a special hook? add_action( 'delete_user', 'my_delete_user'); ...
1
vote
2answers
398 views

Wordpress Image Attachment using remote image

Is it possible to use remote image as wordpress attachment? * Not stored on our server.. How about the code/script? i see that attachment is act as post in database.. seems it's possible. UPDATE ...
1
vote
2answers
209 views

Allowing post attachments without allowing to insert in text

Is there a way I can allow the user to attach images as attachments to a post without allowing him to insert them within the text itself? Ideally the Upload Media button remains the same but the image ...
1
vote
1answer
326 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
2answers
219 views

Getting the ID of any image for use in functions.php

I've added two custom fields to attachments on my site, so the user can add a special image credit. I'm trying to write a function that looks to see if either of the custom fields are populated, and ...
1
vote
1answer
78 views

Where does the gallery shortcode gets its attachments from?

I know that media are an attachment post type that are children to a post, but how are galleries stored in WordPress?
1
vote
2answers
336 views

Validate data on attachment_fields_to_save

I'm very glad that there is such a dedicated website for WP. My problem is data validation upon saving attachment fields. I have added many custom fields to attachment/media library dialog, most of ...
1
vote
1answer
393 views

Set attachment tags from attachment's custom field data

I currently have a custom field added to my attachment's form called artist_credit using the hook attachment_fields_to_edit. When a person enters a name into the artist credit field, I want it to (if ...
1
vote
1answer
609 views

How to protect post attachments related to a custom post type, from non-logged in users, on 1 subsite of a multisite installation?

I'm developing a simple "member's only" section within a website, with the sole intention of allowing the client to post files for their members. I've come to realize quickly that the posts' ...