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

0
votes
1answer
68 views

Exact image sizes

I am trying to define an image size of exactly 290 height x 180 width for all images uploaded to my WP site. I tried updating image sizes under Settings->Media->Image Sizes but these are only max ...
1
vote
0answers
126 views

Custom image sizes add to metadata

I want to put resized files in original file metadata. //Original file $aid = wp_insert_attachment($attachment, $file['file'], $post_id); $a = wp_generate_attachment_metadata($aid, $file['file']); ...
1
vote
0answers
51 views

What is the best way to store thumbnails for a non-image attachment?

I'm in the process of extending Document Gallery to support generating and displaying thumbnails for each document. I've got thumbnail generation under control, but I'm curious as to what best ...
1
vote
1answer
2k 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.
2
votes
1answer
136 views

Impossible to get Attachments Outside Wordpress?

My page (outside the wordpress install) begins something like this: global $wpdb, $wp_query; define('WP_USE_THEMES', false); include_once 'word/wp-blog-header.php'; $args = array( ...
0
votes
0answers
22 views

Is there a way to add Reattach and Unattach links in image gallery?

For some reason the Reattach and Unattach links in Media library is gone. Is there a way to add these from functions.php?
1
vote
1answer
592 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 ...
0
votes
1answer
150 views

Correct Syntax for uploading files to custom directory in Wordpress

I have current PHP code that works when attaching files on a form. The files have to go to a certain directory. I know that while attaching in Wordpress I need to use a different syntax. However, I've ...
0
votes
1answer
62 views

How can I get a comment ID on Submit?

I've added an attachment field to my comment form. It stores the files on Amazon AWS and writes the URL, user ID, post ID, and a few other things to a custom table. I'm having some difficulty getting ...
6
votes
2answers
155 views

Is it possible to Schedule Attachments in Wordpress?

As it's fairly well known, it is possible to schedule Posts in Wordpress for publishing. Also Attachments are actually Posts (in the more internal, technical meaning). So the question that bothers ...
1
vote
0answers
137 views

Rename attachment filenames to attachment ID on upload

I have been trying this code out (based on this Change attachment filename ), it does not work properly. For instance, featured image is not being displayed in admin panel single post, neither are ...
1
vote
0answers
27 views

Change default selection for “Embed or Link”?

I want the default ATTACHMENT DISPLAY SETTINGS for media files (not images) to be set to "Link to Media File". I have found update_option snippets for images, but not audio/video. Can't find the media ...
1
vote
1answer
806 views

How to paginate attachments in a secondary query as gallery?

I have this code that shows all images attached to my post-type. Is there a way to paginate those? I have like 25 pics and I wan't to avoid scroll as much as I can. Code: <div class="galleries ...
3
votes
2answers
563 views

Add a YouTube or Vimeo video as a post attachment?

I'm developing a gallery plugin and I was wondering if I could add a YouTube and Vimeo "embed" option to the media uploader to be able to add YouTube and Vimeo videos as attachments to a post instead ...
1
vote
2answers
338 views

copy attachment title to description and alt text

I have a blog with a lot (over 1000) images. Each image has a meaningful descriptive filename. Wordpress has title caption and description fields for images. What's the easiest way to batch process ...
0
votes
1answer
1k views

File upload from front-end form (as attachment) not working

I have a front-end form that is supposed to allow the user to upload a CV which is then sent along with the rest of the form as an attachment. To do so I have used wp_handle_upload() like so: if ...
0
votes
1answer
1k views

Upload file to front-end form and send as email attachment

I am trying to create a front-end form that has an option to upload a CV (so pdf or word format) that I would like to be able to send as an email attachment. I've read a few articles and tutorials the ...
0
votes
1answer
85 views

How can I add a default description to uploaded files?

Is there a way to add a default description for media files as soon as they are uploaded to WordPress? Specifically, I want to modify the code here to extract the text from PDF files and include it ...
0
votes
1answer
141 views

How to retrieve “custom url” from image attachment in wordpress

I have uploaded a bunch of images to a post and set the 'custom url' for each of them in the media uploader. How can I retrieve the custom URL assigned to each image into $caption_text= at the ...
0
votes
3answers
1k views

Get wp_get_attachment_url outside of loop

I need to get the featured image outside the loop. This is so that I can have a different full-screen background image for each page, set by the featured image. After doing some research I was able ...
0
votes
0answers
251 views

Prevent Duplicate Attachment When Using wp_insert_post

I am trying to use wp_insert_attachment while using wp_insert_post. It's successfully creating the post and attachment. It have no problem if I only use the wp_insert_post function, but when I ...
0
votes
1answer
221 views

Unable to get wp_get_attachment_url to show

I'm trying to show a link to the full size image of an attached image. I took a code for Wordpress' Twelve Thirteen theme: <?php $metadata = wp_get_attachment_metadata(); printf( '<span ...
0
votes
1answer
107 views

Possible to “Attach” images to multiple posts without uploading twice from Add media Section?

How can I attach images to a post which have already been attached to other posts without having to upload them twice? I don't want to insert the images into the post, I simply want to attach the ...
0
votes
1answer
102 views

redirect attachment page to category page

I'd like to prevent google from indexing my attachment/image pages. So for the images I placed in my posts that's no problem - I just redirect the attachment page to the post parent by creating a new ...
0
votes
1answer
181 views

Remove attachment from database

Is there a way to bulk remove attachments from WordPress database but not delete the actual files from the server? Sort of like the opposite of http://wordpress.org/plugins/add-from-server/
0
votes
0answers
35 views

Limit number of uploaded attachments of specific context

I am assigning a custom _wp_attachment_context meta to attachments with specific usage. In my case - favicons. I also took advantage of the WP Customizer so my users could upload icons using extended ...
0
votes
2answers
98 views

Uploaded attachment not set as featured image

The following code uploads an image which I want to associate with a custom post type. $upload_overrides = array( 'test_form' => FALSE ); if($file_errors['error'] == 0) { if($new_reseller_id = ...
-1
votes
1answer
1k views

How to find attachment by it's name?

Is it possible to get attachment id by its name? And at once may be it's possible to get parent post, to which this attachment is assigned?
0
votes
1answer
254 views

save_post not working with attachments

I've made a Meta Box for Posts and Pages, and while testing added Attachments too. But, curiously, the hook save_post does not fire. $cpts = apply_filters( 'my_filter', array( 'post', 'page' ) ); // ...
0
votes
0answers
269 views

A attachment file with a php form in wordpress?

I am making a PHP form in WordPress. I would like to receive a notepad or PDF file along this form when user submit form. I am getting all this in email using mail function in a body variable for ...
4
votes
1answer
88 views

complex restriction of items in media library

I have a need to limit items in the media library for users without a specific capability. There are a lot of examples out there for how to limit them to only items that a given user has uploaded, ...
0
votes
1answer
121 views

Retreive tags from attached post for media on page

I am working on a custom template file that pulls all images in my Media Library with a specific tag. I was able to get this working with some help from the community, it also shows the title of the ...
0
votes
1answer
507 views

Get title of post image is attached to

So I found this post: Find the post an attachment is attached to and implemented Chip's suggestion but having a weird outcome. I am trying to pull the title of the post that the specific image is ...
0
votes
1answer
430 views

Import Attachments - not attaching to post_parent

I've set up a dev site for a client, for who we're overhauling their existing site. One thing I wanted to do is import all their existing news posts, and carry over any images attached to those. I've ...
0
votes
1answer
93 views

Get a Page's attachments in Gallery order

Having created a page and a gallery within that page, I would like to retrieve all the images in that gallery in the order they are set when the gallery is created, i.e. the order which I drag them in ...
0
votes
2answers
255 views

Associate an existing image with a post

I'm trying to associate an existing image from the media library with a post (It's a custom post type), If I use wp_insert_attachment I get a duplicate in the media library, so I'm getting the image ...
1
vote
0answers
66 views

How can I append custom data to images in the editor?

I've added a custom meta field to my image details so that a client can add a number to their photos (a design choice). The data would need to show up under each image (like a caption) inserted into ...
0
votes
0answers
95 views

List Post Attachments Conditionally Based on File Name

I am trying to display the attachments of a custom post type based on their file name (numbering at the end) and then assign it to a title. I have 10 pre-defined titles that I want to link to a ...
0
votes
1answer
134 views

Post images not displaying as attachments

I am trying to display the images attached to a post in single.php I've used : <?php if (have_posts()) : while(have_posts()) : the_post(); ?> $args = array( 'post_type' => 'attachment', ...
0
votes
1answer
48 views

Show title when inserting single images

I just can't get how to do this. When inserting a gallery I have this output: <a href="path_to_files/image.jpg" title="fancy title"> <img width="150" height="150" ...
1
vote
1answer
1k 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) ...
0
votes
1answer
128 views

Get Attachment Image Class by attachment id

I want Get wordpress media library image class. I have attachment id and I tired this but won't able to get it. print_r(wp_get_attachment_image_src( $attachment_id, $size, $icon, $attr )); How can ...
1
vote
1answer
74 views

Applying class to links around self hosted images embedded to posts/pages

So I need to add a class to links around the images for lightbox purposes. But only to images from the upload directory, not to external ones. I've found this solution by @TommiForsström here: ...
0
votes
1answer
48 views

Move caption in on attachment page

I am looking for a way to edit the way Wordpress’ native gallery displays images when clicked on. Specifically, I need to move the title below the image. A more detailed explanation: I setup a ...
3
votes
1answer
357 views

Bulk term assignment for attachment taxonomies

I've created a custom taxonomy for attachments. Everything ok, but now I want the ability to bulk assign its terms to attachments using the default wordpress media admin ('upload.php') bulk actions. ...
1
vote
1answer
349 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 ...
0
votes
1answer
124 views

list of attachments: wp_get_attachment_link works, wp_get_attachment_image does not

On single.php theme template file, I'm displaying the post's list of attachments. global $post; $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' ...
0
votes
1answer
281 views

Show selected images on top in Media Manager

I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction. I have a custom ...
0
votes
1answer
330 views

Get all attachments by custom taxonomy - term

I want to make custom taxonomy (gallery) and terms (name1, name2, name3...) Add images into media tab and then retrieve all images from same term. Look like simple task, but I cant manage it. I ...
0
votes
1answer
67 views

Custom attachment field dissapearing

I'm adding a custom attachment field to the media uploader using WordPress' "attachment_fields_to_edit" and "attachment_fields_to_save" filters, which works fine initially after uploading an image ...