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

2
votes
2answers
3k views

How can I hide media library images from general users?

As an admin I really like the features and functionality of the WordPress 3.5 media manager. With a multi-user site however all users can see all images in the media library - whether uploaded by ...
0
votes
1answer
61 views

Setting name of attachment URL

I have a problem I need to fix with the URLs that are generated for the attachment pages of images with metadata. I’m working on a photography site where individual photos are displayed as ...
0
votes
1answer
116 views

Media/attachment urls don't redirect with fake URL structure

I'm having an issue with media/attachment files and I'm not quite sure how WordPress is returning the URL that it does. I've noticed that I can add anything as a subdirectory structure before a media ...
0
votes
3answers
3k views

How can I get a different image size, if all I have is the link?

For various reasons, I can't use Wordpress' built-in Thumbnail functionality. What I want to do instead is to use the first image in the post as the thumbnail. Here's what I found in the codex: Show ...
0
votes
0answers
19 views

Change default options on attachment page

I'm currently adjusting someone's plugin, and they're pulling data from the attachment page. Rather than edit the whole plugin entirely, I'm after a quick fix. Is it possible to change the wording on ...
0
votes
2answers
285 views

Get attached media only

I am using wp_query to get uploaded medias. Everything is working fine, but wp_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media ...
0
votes
1answer
86 views

Save attachment ID instead of URL in custom field

I am testing several frameworks (currently Vafpress) to help me creating custom meta boxes. I need to save a lot of attachments with my posts but noticed that the attachment is saved with its full ...
0
votes
1answer
72 views

How can I hide previous_image_link() on first attachment page?

I'm using previous_image_link() and next_image_link() to show thumbnails in my image.php template page. I'm surrounding the thumbs with some styling, so need to be able to hide the whole previous ...
2
votes
1answer
650 views

Get attachments (get_posts) and WP 3.5 new uploader

I'm using get_posts() to get attachments from the post and use it in the slider. The issue is new uploader doesn't have that "Gallery" tab which was perfectly suitable for this. It also seems to be ...
0
votes
0answers
115 views

How to include editable PDF in wordpress

I need to include a Existing PDF in website, where user can either fill or download it. I tried to use visual form generator, but it doesn't like actual form and I need to allow a user signature. ...
0
votes
0answers
39 views

Incomplete attachment page

I am using the twenty-thirteen theme and my attachment page chops off the footer & image. Have a look at my screenshot. You can see that it shows the title but it doesn't show the image and the ...
0
votes
0answers
44 views

Lots of attachments is causing slow load

I have a wordpress site with 400k unattached images. When I try to view any single attachment page it loads quite slow. Is there anyway to improve performance?
0
votes
0answers
56 views

All images from posts of specific category

I'm photographer and am developing my own portfolio, it's in the final stage. I'm trying to get all images from posts in a specific category. I can actually get all images from all posts, but they ...
0
votes
2answers
398 views

filter get_children to return all mime types EXCEPT 'x'

Like it says on the tin - Im trying to create a list of post attachments that includes everything except say audio, which I'll feed into a player instead. The filter needs to be generic: 'audio' ...
0
votes
0answers
15 views

How show image upload whit guest in single post? [duplicate]

I use this code: function.php function insert_attachment($file_handler,$post_id,$setthumb='false') { // check to make sure its a successful upload if ($_FILES[$file_handler]['error'] !== ...
0
votes
1answer
27 views

Delete attachment with post

I'm trying to post a delete Link for a user so he can delete his own entries: global $post; if ( !current_user_can( 'delete_bkroadkill', $post->ID ) ) return; $link = "<a href='" ...
3
votes
1answer
214 views

Auto delete WordPress images/thumbnails (all sizes) and featured after X days/hours, or similar?

I am looking for solution to auto delete images of old posts in WordPress site. I want to hold images of current 50 posts, others should be deleted automatically. It can be function to delete on time ...
1
vote
1answer
250 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 ...
0
votes
0answers
76 views

How to show post attachment image

i am going to create a slidershow by post attachment in single.php. i use this code but the result is null. <?php if ( have_posts() ) while ( have_posts() ): the_post(); ...
0
votes
0answers
32 views

Drupal 6 to Wordpress migration - media attachments

Migrating was simple with a few SQL queries that I found on a blog. But I was unable to find a way to importing images as media attachments on the Wordpress site. Any help is really appreciated.
0
votes
2answers
92 views

Short of raw SQL, can I query for multiple attachment metadata that have a given array key?

With raw SQL through $wpdb, I believe that I could do something along the lines of this (untested): SELECT post_id, meta_value FROM postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value ...
1
vote
3answers
349 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 ...
0
votes
1answer
63 views

Importing Attachments with No Extension

Is there an extension, or a technique, during Wordpress import to pull in an attachment URL that doesn't have a file extension? I'm trying to import a Square Space blog into Wordpress. Most of the ...
0
votes
1answer
18 views

What is the best way to associate multiple images to one page?

WP has one major problem and that's image handling. Each image is treated as a post and if you "attach" an image to a page, you cannot un-attach it. Without installing a gallery plugin and without ...
1
vote
1answer
753 views

Is it possible to Hook/Filters Attachment Creation?

Is it possible to hook or filter the attachment creation process? More specifically is it possible to hook into the attachment creation so that I may parse the attachment’s filename, populate the ...
3
votes
1answer
287 views

How do I delete all generated images from my server except those currently used in posts

I have a new set of image sizes for my site's in-development theme. My server is filled with old image sizes, most of which have never been used. You've heard this one before, right? The Question How ...
0
votes
1answer
140 views

How to remove attachments from main query via pre_get_posts?

I'm struggling to find a solution to the following problem. The main query should only check pages and selected custom post types for the selected post type name. address.com/flower-post-name ...
7
votes
4answers
5k views

Broken? WP_Query and “attachment” as a post type

I have a gallery attached to a page. On that page, I'm running the following query: $events_gallery = new WP_Query( // Start a new query for our videos array( 'post_parent' => $post->ID, // ...
0
votes
1answer
34 views

Set the default category of an attachment

I wanted to apply the same categories that exist for posts to attachments, so I wrote this code: function wpmediacategory_init() { register_taxonomy_for_object_type( 'category', 'attachment' ); } ...
5
votes
1answer
10k views

How to get attachment file name not attachment URL

I'm using this code to list the image attachments of a post: <select name="chb_homes_for_sale_specifics_floor_plan" style="width:100%;"> <option ...
0
votes
1answer
159 views

Redirect Attachment Page to Attachment

I'm trying to change my attachment page to just automatically redirect to the attachment. Here's what I've tried: Get attachment ID and redirect to that URL: $urlArr = ...
3
votes
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 ...
0
votes
0answers
48 views

Remove link to post thumbnail in next_image_link() in single-attachment.php

I've added navigation to single-attachment.php: <div class="navigate"> <div class="previous"><?php previous_image_link( false, '&nbsp;'); ?></div> <div ...
1
vote
1answer
16 views

Is there a move_attachment_file() function in wordpress?

I would like to move (or copy) an attachment from the the "standard" uploads directory to another directory and at the same time make sure all the attachment metadata is updated to reflect the change ...
0
votes
1answer
2k views

How can I display a link to a post's (Word doc or pdf) attachment?

I'm using the code below to first grab the post's attachments (if they're either a Word doc or pdf file), then echoing the url of said attachment. This works great on the first post on a page. ...
1
vote
0answers
127 views

Reorder “menu order” of attachments to another predefined order

I want to show photos attached to a post in a gallery using the built-in system with a custom order. Currently with the [gallery] shortcode it is posible to order it by name, by upload date, by ID, ...
0
votes
1answer
2k views

wp get attachment image always gives me thumbnail

I have an image which should be output on the page. The space is limited (width-max = 209px). Now I have to provide the image in a scaled size, if the user doesn't do it. This is my code: $src = ...
0
votes
0answers
14 views

Attaching a media file to email link from webpage? How?

When someone clicks a link on my webpage I want it to come up as an email with a document from my media folder already attached to it. How do I do this? Thanks!
0
votes
0answers
100 views

Password protected category based attachment/media list?

I am working on building a custom template, and I'm running into some trouble using the password protected feature for wordpress pages. Basically, the content from the page I have published and set ...
0
votes
1answer
49 views

Attach an image to new posts

I am trying to attach an image to the body of a post. The post is created. The image is added to the Media Library. The thumbnail is added to the post. The images do not get added? $attachment = ...
1
vote
0answers
31 views

Add an attribute to attachments

Currently attachments have title caption alt text description I would like to add another attribute to that list (e.g source). How can I do this ?
0
votes
1answer
152 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
35 views

Post attachments doesn't show after manual db import

I have wp db exported from domain www.domain1.com. I did manual database import using phpmyadmin to domain www.domain2.com. In database for particular post on new domain I have attachment image link ...
0
votes
1answer
27 views

wp_insert_post featured image from library

I know there are a lot of posts about it, but I don't want to upload a URL image to the library, I already have the image in the library and its IP. How can I use it with wp_insert_post?
0
votes
1answer
51 views

Ignore image urls in wp_query search

I'm doing a keyword search using wp_query as so: $wp_query = new WP_Query( 's=' . $_GET['s'] ); It is returning a post that has $_GET['s'] in one of its image URLs, and I don't want this to happen. ...
0
votes
0answers
538 views

Set thumbnail from URL, by grabbing image in functions.php

So I've written a whole bunch of functions, which are used to display Vine videos. I then have a shortcode which outputs the code. The last thing I have to do is set the post thumbnail. I want to be ...
0
votes
0answers
99 views

Advanced Custom Fields: wp_get_attachment_url not working, attachment page says “Missing Attachment”

I used Advanced Custom Fields to add a file upload field to a custom post type. I have the following code in the template for this custom post type: $file = get_field('file'); echo ...
0
votes
0answers
35 views

How to force attachment size for every post

I created a custom size like this : add_image_size( 'my-size', 615, 9999 ); Is there anyway i can force the ATTACHMENT DISPLAY SETTINGS SIZE to be always ('my-size') for every attachment?
0
votes
0answers
73 views

How to set/force the size of the image/attachment uploaded by frontend form?

I have a front end form to let users upload images to my website and i set the post attachment image like this: // find the most recent attachment for the given post $attachments = get_posts( ...
3
votes
2answers
359 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.