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
1answer
607 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 ...
2
votes
1answer
690 views

query attachment images … if no attachments -> get attachments of parent page?

I use this to query all attachments of the current page or post I'm on … $query_images_args = array( 'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => ...
2
votes
1answer
550 views

Replacing with(out) regex link to attachment by links to files

I tried to do it myself but I have really hard time with Regex (regex is hell. I just don"t understand). Anyway, I think this would be usefull to some people. The context is that we use a plugin to ...
2
votes
1answer
284 views

How to set author for post AND post attachments

I have multiple author accounts on one of my WordPress installs. Often I will create a post, and set the author to be a different account. However, when I upload images into that post, their ...
2
votes
2answers
603 views

Getting ID from ajax response of async-upload.php

Its a wordpress+jQuery question. Can't post it on stackoverflow because i believe it involves wordpress knowledge too. What I am trying to achieve: I am attaching the wordpress async media uploader ...
2
votes
1answer
352 views

Set WordPress Featured Image For All Post Slugs Matching Image File Name in Specified Directory

I have a bunch of old posts on a blog that I would like to assign a featured image to. I have retrieved all the images I would like to use for each post. I saved each image file name after the slug ...
2
votes
1answer
812 views

How to add attachment without uploading?

When save post, I made dir in wp_uploads_dir, and copied 2 files and one folder in this dir. Now I want to do the WP_insert_attatchment process to make the 2 files as attachements. How can I do it? ...
2
votes
2answers
662 views

Display info from custom fields in all images' HTML

Okay, I've been working on this all day and can't find the solution anywhere. I've created a custom field within the image upload screen (info first found here). The field stores the name of a ...
2
votes
3answers
2k views

Change image link: wp_get_attachment_link

Can anyone help me filter wp_get_attachment_link so that a particular occurence of it links to the 'medium' or other size image rather than the full size. I have the following in a page template: ...
2
votes
1answer
160 views

Multi-line captions on attachments

How can I change the 'Caption' text input to text area, to allow for multi line captions on media uploads?
2
votes
1answer
840 views

Post Auto Draft Issue

I've made custom post type without title and editor and I use custom taxonomies, custom fields and attachments to form a post. My title is generated from custom taxonomies and custom fields (or "ID #" ...
2
votes
1answer
277 views

Make individual attachments private?

Is there any way to make individual attachments private similar to how a post can be made private? I've looked through various plugins but none really seem to do the job. They usually make all ...
2
votes
4answers
845 views

Separate attachment images from post loop

I'm trying to create an array of images for a slideshow gallery script, so need to separate the images from the post loop - any ideas of the best way to achieve this and make it easy to add images? I ...
2
votes
1answer
132 views

Getting attachment images is cloning some of them

So, i got this code to retrieve the images inserted in a gallery within a post: <?php $args = array( 'post_type' => 'attachment', 'numberposts' => -1, ...
2
votes
1answer
734 views

How to add multiple checkbox elements to media attachments?

Based on solved question from: How to add a checkbox element to attachments editor with example Theres an example of multiple Checkboxes, for example: Colors, patterns, etc... A grouped list but ...
2
votes
1answer
506 views

Getattachment next and previous by author only

Im trying to get the next and previous attachment by the user its currently displaying, this is what I have and it works great except it gets all of the attachments instead of just the ones from a ...
2
votes
0answers
118 views

Pulling Post Image Attachments in WordPress 3.9

For some reason the functions I'm using for pulling post images/attachments isn't working after updating to 3.9, has something changed in the way we pull attachments? The code I'm using in single.php ...
2
votes
1answer
125 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( ...
2
votes
1answer
479 views

rename attachments based on parent-post-title on upload

I know there a some functions already avaible here for this task, but none of them seem to work as needed. The best way seems to me adding a filter to wp_handle_upload_prefilter like kaiser does in ...
2
votes
1answer
183 views

Rename attachments during upload no matter what filetype

Here's the function I use for WP to rename images during upload on the fly and set the image's filename to match the post slug. function wpsx_5505_modify_uploaded_file_names($arr) { // Get the ...
2
votes
0answers
77 views

Page Attachment Permalink Structure based on Menu Order?

I've been on a quest for the past couple of days reading up on Rewrite in WordPress but still can't seem to figure out how to accomplish this. When using pretty links in WordPress, media attached to ...
2
votes
1answer
103 views

Converting Attachment to Images?

I've had no problem using lightboxes before with attachment images, but I've switched to a new theme called Quicknote and it seems that attachment images now instead link to the attachment page. ...
2
votes
1answer
327 views

How to set a default meta value for custom field

I have setup a custom meta_key for attachments. Since it is a radio button with Yes/No options, and the default value is always Yes, I need that this default value is saved into the db when the ...
2
votes
2answers
232 views

Find first image on paginated post for Pinterest

I've been looking for days, yet can't find a good answer. Perhaps the SE crowd can be of assistance. Any help is much appreciated. I am using a custom-coded pinterest button included on posts that ...
2
votes
0answers
326 views

Attachment 0×0 size error [closed]

My theme uses 8 different thumbnail sizes. I imported my local installation to the final server using phpmyadmin to export the wordpress database. Everything is smooth except for the attachments: many ...
2
votes
0answers
426 views

Custom attachment permalink structure [closed]

I have 10 images attached to each of a custom post type. My permalink structure for the custom post type is: example.com/post-type/post-title I am using the Wordpress Attachments plugin. My ...
2
votes
0answers
544 views

How can I get an image from the uploads dir and enter it in the media library? [closed]

I want to develop a script that: Gets an image from a post's content and removes it (it's hosted on another website) Uploads it in the uploads directory Adds it in the media library and ...
1
vote
4answers
7k views

How to get Page/Post Gallery attachment images in order they are set in backend using WP_Query()?

I am trying to retrieve all the images from the Gallery of a page in the order they are set in the backend. So far I have: $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query( ...
1
vote
2answers
2k views

page template for attachement page?

hey guys, I couldn't find anything on the web. Is it possible to have custom template for the image attachement page. I wonder if it is possible to add a navigation to the image attachement page so ...
1
vote
1answer
989 views

exposing attachment uploading to the front end — delicate

i'm probably breaking a few common sense rules here. is there a way to utilize wordpress' bake in attachment file handling for an upload form within a theme template? yes, the front end -- i ...
1
vote
1answer
598 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 ...
1
vote
1answer
45 views

Is there a plugin which allows me to save additional, invisible content per post?

For a blog project, I need to be able to attach content to each blog post which isn't visible to the casual reader but to all editors. Think of it as a collection of reference materials, comments and ...
1
vote
2answers
212 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 ...
1
vote
2answers
449 views

Link all Wordpress images size

How i can link all different images size upload in wordpress? I've definited different size image with the plugin simple image size so i'ld like show in single post, links to all new images example ...
1
vote
1answer
93 views

How To Grab All Type Of Attachments, But Images?

I need to get all file attachments which is not an image, 'post_mime_type' only accepts "any" or specific mime types, How to grab all type of attachments, but images?
1
vote
2answers
937 views

Removing width and height attributes from wp-get-attachment

I'm using this http://www.ghosthorses.co.uk/production-diary/removing-inline-img-dimensions-for-responsive-wordpress-websites/ to remove the height and width attributes of images. Everything works ...
1
vote
1answer
81 views

How can I query posts with newly uploaded images?

I have a custom post type for events. A couple of days after each event photos are sometimes uploaded and attached to the event they were taken at. I want to highlight these image gallerys somewhere ...
1
vote
2answers
1k views

How do i show wordpress attachments from current post?

So with my blog i have a photo attachment page but it only shows to photo's at a time, and those two photo's are used as the navigation and i hate that. I want the attachment page to show all the ...
1
vote
2answers
1k views

Insert attachment ID in custom field from media uploader

This is what I want to do: In the media uploader, add a link "Use this attachment ID as custom field". Add the attachment ID in a custom fields meta box. I've searched for hours for a plugin that ...
1
vote
1answer
381 views

How grab first two image attachments?

I am grabbing an image that is uploaded to that post working with this function: wp_get_attachment_image_src <?php $images = get_children( array( 'post_parent' => $post->ID, ...
1
vote
2answers
2k views

How to single click to download image in single post

i have attacment.php like this. <?php if ( $attachments = get_children( array( 'post_type' => 'attachment', 'post_mime_type'=>'image', 'numberposts' => 1, 'post_status' => ...
1
vote
1answer
2k views

Insert an image into a post by API

By using the code below, I can create a new post and upload an image to wordpress's upload directory as a attachment through a form's submitted data. $new_post = array( 'post_title' => ...
1
vote
1answer
823 views

Custom page template to display all image attachments

I am tryin to insert all pictures in media to page. By meaning all pictures, everything added in blog. I ve been looking this feature all day. Is there any shortcode for that or something easy to make ...
1
vote
1answer
876 views

why when I try to insert an image attachment along with a post does wp_get_attachment_url give me a very wrong file path?

I am using a new blog on WPMS (3.0.1, updating is not an option) to aggregate posts (and their featured image) from a few blogs on the same install, and I have to do it programmatically rather than ...
1
vote
3answers
3k views

use wp_get_attachment_image() to show attachments

I really hope this is a facepalm moment, b/c i'm getting frustrated with this. Making a quick loop to show certain attachment images. lifted it almost straight from the codex but ...
1
vote
1answer
280 views

Sorting By Custom Posts With Attachments

I think I've got this figured out and I'd like to make sure I'm not missing anything obvious. My goal is to prioritize a list of results by custom posts with attachments. So, I have a query returning ...
1
vote
1answer
709 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
799 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
683 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' => ...