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

3
votes
2answers
362 views

Use an attachment in multiple posts

I have an attachment in a post and I want to attach it to another post without detaching it from the first post, using the WP API.
1
vote
0answers
21 views

Delete original attachment files after editing

I am looking to obtain an certain workflow using WP Media Uploader and Image Editor and I am getting a lot of generated images that I do not need and I do not want to keep them. You can see in the ...
0
votes
0answers
9 views

Permanent names of attached files required

Simple: How to delete uploaded file ? Secondary: How to replace uploaded file and to keep its filename (inclusive the path) and all links (inclusive on the whole internet!!!) the same?
0
votes
1answer
632 views

How to get the next and previous image title from attachment or gallery?

I'm trying to build a slider exactly like this in wordpress. I have managed to make the slider work except the next/prev button. I need to get the next image title and the previous image title for the ...
3
votes
1answer
1k views

Uploading Multiple Attachments From Front-End With A Description

I am working on a Wordpress site that has a custom front-end submission form for adding in a post of content type, 'sketchpad'. The form has a section that allows you to upload multiple images with a ...
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
2answers
181 views

Front end file upload returning wrong attachment url

So I'm making a simple file uploader with wordpress where users don't need to go into wp-admin to add a file. I have it working great, it uploads the file to the correct folder..etc but the only ...
0
votes
0answers
130 views

How to search attachments (images) and posts in WordPress of a given post type

I'd like to extend the search functionality in a WordPress blog in order to search a custom post type including its attachments. I got some progress searching posts and attachments, also excluding ...
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
0answers
69 views

Attachment Metadata not updated while uploading audio files

Suddenly, I am having some issues when uploading audio type of file in wordpress. previously, when I uploaded .mp3 files, the attachment metadata of the files were updated accordingly, for instance; ...
0
votes
2answers
163 views

Undoing define( 'UPLOADS', ''.'files' ); to repoint to “wp-content/uploads” folder

Is it possible that by setting the “wp-content/uploads” to use a different folder by using define( 'UPLOADS', ''.'files' ); I have effectively changed all the paths on a permanent basis and if that is ...
0
votes
2answers
1k views

Remove “attachment/” from the URL of attachment pages

Currently, the media for a page on /hello-world/ is shown on /hello-world/attachment/image-name/. Is it possible to remove attachment from this URL, and make it /hello-world/image-name/?
0
votes
1answer
181 views

How can i catch (with get_posts) attachment file (pdf, images) from a post when i have only inserted it from media library and it isn't upload for it?

I'm sorry for my english. I discover a strange behavior in WP get_posts when i try to detect from a post an attachment (in my case a pdf file) inserted from the library. This is my code: ...
6
votes
1answer
5k views

remove links from images using functions.php

I am looking for a way to remove the attachment link from images in the post content. I would like to add this to the functions.php in my theme. I know you can disable this in the post on a per ...
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
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
0answers
127 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 ...
2
votes
2answers
539 views

Best way to programatically add “rel” attributes to page and post images

For single posts and pages, I would like to add certain rel attributes to all the images on the contained therein added with the "Add Image" functionality on the edit screen. The attribute would be ...
1
vote
1answer
1k views

Creating a multi-file upload form on the front end for attachments

I am trying to create a public form where users can upload multiple images to be attached to a particular post. I am able to get it to work with single images thanks to this post at Golden Apples ...
11
votes
3answers
12k views

How do I get the size of an attachment file?

I'm using the following template code to display attachment links: $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => ...
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?
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 ...
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 ...
1
vote
1answer
810 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 ...
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 ...
3
votes
1answer
1k views

Is it possible to query specific Wordpress Attachment files (.ppt & .pdf) and output them in a list?

The files are .ppt and .pdf files (not images). Will it be possible to query these types of attachments and output it in a unordered list?
0
votes
1answer
336 views

Use full size images in a specific gallery

Thumbnails are displaying as 100px however the full size is 130px which is what I want. I want this only in one specific gallery. Also would like to link each gallery thumbnail image to an external ...
1
vote
0answers
139 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 ...
5
votes
4answers
3k views

Change attachment filename

Is there a function that allows me to change the filename of an attachment, based on the Attachment ID I have? Thanks! Dennis
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 ...
3
votes
1answer
2k views

Programatically creating image attachments from local URLs and setting featured image

I'm currently working on importing an MovableType blog into WordPress. The blog has several thousand posts, and each post has an image associated with it. The export file contains references to each ...
-1
votes
1answer
415 views

how to edit attachments?

when attaching eg. files to a post, how can i edit/delete them afterwards? couldn't find anything in the post editor. thanks
1
vote
2answers
342 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

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 ...
5
votes
1answer
1k views

Saving images from Gravity Forms repeatable File Upload as post attachments [closed]

I am trying to upload multiple images as attachments to a post using Gravity Forms and the Gravity Forms + Custom Post Types plugin. I have a repeatable File Upload field using the Gravity Forms ...
1
vote
1answer
287 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 ...
2
votes
4answers
3k views

get attachments for all posts of particular post type

I'm making a widget that shows a set of images from recent custom posts. I want to run the following query: SELECT p.* FROM wp_posts p WHERE post_type='attachment' AND post_mime_type LIKE 'image%' ...
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
2answers
99 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 = ...
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
4k views

attachment page template? only show attachments for current post?

hey guys, didn't know that, but the attachement page (i'm using attachment.php as template) is actually looping through ALL ever uploaded attachments to my blog! I just want to use it in order to ...
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 ...
4
votes
1answer
89 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
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 ...