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
480 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
79 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
336 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
239 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
221 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
633 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
374 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
275 views

Don't show attachments if they are inserted in post

I have attached images that I have inserted into my posts but they also appear in the attachments box at the bottom of the post. I'd like to know how to make them not appear in the attachments box if ...
1
vote
1answer
535 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
492 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
219 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
2answers
261 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
79 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
371 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
441 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
659 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' ...
1
vote
1answer
444 views

Exclude images from “inserted into post” when trying to get attachments

I have here the coin-slider which takes all pictures from the gallery. I get the attachments through the following code: $attachments = get_posts(array('post_type' => 'attachment', 'post_parent' ...
1
vote
1answer
279 views

What is the “icon” parameter in wp_get_attachment_image_src used for?

On the reference page for wp_get_attachment_image_src, there is a parameter called icon and it only says: $icon - (bool) (optional) Use a media icon to represent the attachment. Default: false ...
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 ...
1
vote
1answer
350 views

Is it possible to list post attachments in a sub URL endpoint with a dedicated template?

Wordpress provides templates for displaying media attached to a post or page (attachment.php and more). They're also displayed with nice permalinks, such as: ...
1
vote
1answer
754 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 ...
1
vote
1answer
292 views

Custom field not updating when value is empty

I've added a few custom fields to the WordPress image uploader using the hooks attachment_fields_to_edit and attachment_fields_to_save. Everything works very well, except when a field is erased by the ...
1
vote
1answer
861 views

How to remove attachments size attribute [duplicate]

Possible Duplicate: Prevent Width and Height Attributes in Image Tag Output i would like to remove the width="512" height="128" attributes on an attachments this method is fine on images ...
1
vote
1answer
106 views

media 'path' issue / concern when bringing files live

I'm currently developing a site we have installed on a sub-domain. 'beta.mysite.com' We will eventually, be moving site to it's root domain. 'www.mysite.com' Problem? any post type attachment / the ...
1
vote
1answer
1k views

attachment.php code or tutorial

I am confused about the exact purpose attachment.php ( and image.php) . I notice many themes dont have them. If single.php displays the image the way I want then is it OK to leave it out. On the other ...
1
vote
1answer
324 views

Wordpress adds extra width to post images container boxes

when I insert an image into a post, the <div> that contains that image (and thus any caption) is set to be wider that the image itself. For example, I have added an image that is 211px wide. ...
1
vote
2answers
779 views

How to redirect 'file url' to 'post url' i.e. in attachment.php

I've just started using the attachment.php template on my site. What I'd like to do is redirect all images in posts that used 'file url' to 'post url' and my new attachment.php template. Is this ...
1
vote
3answers
1k views

Control attachments menu order with jQuery Sortable

I've managed create a metabox that lets me upload and then fetch the images and then also been able to add jquery ui sortable to be able to sort the images, however I've no idea how to add actual ...
1
vote
1answer
287 views

Handling image uploads without thickbox

Ideally what I'd like to do is hand a file to a function that returns the file as an attachment of the current post. Just as though it had been uploaded via the thickbox media uploader, but without ...
1
vote
3answers
2k views

Hide “Gallery Settings” and “Insert into Post” button from Attachment window

I'm using different method to form a gallery in Wordpress, so I would like to hide an option to insert images and galleries into post for anyone but Administrator. Can someone show me an example how ...
1
vote
1answer
556 views

get post attachment using ajax

I'm developing a plugin and I'm trying to get the url's from a post's attachments with ajax. If the user is on a single.php page. After some seconds, I'm sending an Ajax request, getting all the ...
1
vote
2answers
236 views

Pull images from the gallery

I am building a template where wordpress is being used primarily as an image CMS, I am pulling the first image from the content section of each post. <img src="<?php echo grab_image() ?>" ...
1
vote
1answer
605 views

How do I modify the “Insert Media” lightbox in the admin to only show media items from a category?

I am attempting to resolve a problem I continue to have with the media library. Essentially, what I am looking to do is "automatically" assign media which is uploaded from a custom post type "edit ...
1
vote
1answer
2k views

Link Attachment Image to Category

How do you link an attachment image to its category? function wp_attachment_image($size = thumb) { if($images = get_children(array( 'post_parent' => get_the_ID(), ...
1
vote
2answers
295 views

Why can't my admin account manage attachments on a custom post type with a unique capability type?

I've created a custom post type called 'directory' and assigned it the capability type of 'listing'. It has a unique capability type because I want to restrict Contributors to only be able to ...
1
vote
0answers
64 views

How to make a customized “Create Gallery” tab in the 'Add Media' window?

I'm developing a plug-in and wanting to make a customized version of the the "Create Gallery" tab of WP v4.0, but have the resulting output (i.e. what gets inserted into the TinyMCE editor) to be ...
1
vote
2answers
298 views

Unable to upload specific .zip file type via frontend in WordPress 4.0

I allow uploading a selected few types of files from the frontend, e.g. .zip, .mp4, .jpeg and .pdf. Till now all these file types had no issues getting attached to the post it is uploaded to. However ...
1
vote
0answers
24 views

Replacing the content of an image attachment using API

I have an existing image attachment, with a given ID. Is there a way, using API (specifically, Python Wordpress XML-RPC), to upload another image instead of the existing one, without creating a new ...
1
vote
1answer
335 views

wp_mail file attachment not being placed in upload folder?

I have a form where I want users to be able to select an image to upload. The image gets temporarily uploaded to the wp-content/uploads folder, is attached to the e-mail and then is destroyed. Right ...
1
vote
0answers
116 views

Clean up images, delete unused image sizes attached to a post type

I found this post: How do I delete all generated images from my server except those currently used in posts which describes how to delete all image sizes but the original uploaded image file. I need ...
1
vote
2answers
72 views

Taxonomy archive + query attachments = duplicate results

I'm trying to get the attachments of a specific term (in its archive page). But the results are showing the resulting images 5 times instead of one. I have multiple loops in this page - one to show ...
1
vote
0answers
49 views

How to limit number of attachments

I'm using Sweet Cake theme. As you can see the portfolio section show all pictures. I want when someone load the site to be displayed items of the first category , instead of everything. How can I do ...
1
vote
1answer
605 views

Return Attachments from Custom Post Type

I'm a fairly new WP developer. I am trying to get my portfolio.php to display all images attached to my custom post type 'portfolio', and then display them in a masonry format. I've managed to get ...
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 ...
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, ...
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 ?
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 ...
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
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 ...