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
0answers
14 views

Display all images except those uploaded via OptionTree

I'm using the following to display all images in media library however, I'd like to exclude images uploaded via OptionTree as these are either banners or logos. $args = array( 'post_type' ...
0
votes
0answers
11 views

Need help with rewrite of Attachment URL [duplicate]

How can I change Attachments URL to example.com/photos/attachment_ID/post_name/attachment_name Thank you
0
votes
1answer
250 views

Change attachment inside the_content using filters

I am in search of a snippet or function that will filter the embedded images inside a post to a custom size I have defined in functions.php. Here is the scenario: A client uploads and add any ...
0
votes
0answers
114 views

Changing attachment page Permalink

How can i change the attachment page permalinks to http://domain.com/photos/%attachment_id%/%postname%/%attachmentname% currently my permalinks set to Custom Structure ...
0
votes
1answer
110 views

Custom Gallery HTML only working when images are attached to post/page

I have changed my gallery html using the posts_gallery hook in the same way as shown here:How to customise the output of the WP image gallery shortcode from a plugin? I've copied the latest code from ...
1
vote
0answers
90 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 ...
0
votes
0answers
123 views

Using WP_Query to get attachment returns empty set

I would like to get the first audio file in the media library filtered by a custom field, but it always returns an empty set of posts. I know that I have to pass 'post_status' => 'inherit' and ...
0
votes
4answers
3k views

Get the attachment URL on single.php

i've been trying to get the attachment URL on single.php, so far this code gets the DIRECT LINK to the image; <?php if ( $attachments = get_children( array( 'post_type' => 'attachment', ...
0
votes
0answers
16 views

Presetting the link of video attached to a Standard Post Format in a custom field

I am trying to create a function that presets the URL (of an attached video in a Standard Post Format) to a custom field when the post is created using a front-end form. (P.S.: All data inputted in ...
0
votes
1answer
16 views

Add link to attachment for old posts

All images from posts have no link set! How I can add to all posts link to attachment ? There is a filter I can inject on functions.php.
0
votes
0answers
34 views

Create a constant download link that always points to latest attachment

I plan to have one attachment per post and the attachments will often be receiving updated versions with different file names. I have an issue where users copy and paste the file url and send it via ...
1
vote
1answer
876 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 ...
0
votes
1answer
90 views

Featured Image URL is Showing but not thumbnail

I added posts from other CMS to my new word press site. For featured images I changed, wp_post table as post ID: 2300 Attachment in "wp_post": ID:3400 post_type: attachment post_mime_type: ...
1
vote
1answer
63 views

Password protect media attachment - share across guests

I'd like to show certain content to people with a password, specifically links to media files like this: <?php if($currentuserid == foobar): ?> <a ...
0
votes
0answers
21 views

How Do Set image Folder For generated thumbnails with wp_generate_attachment?

I wrote an import app to create posts with several attached images. The files are already on the server under wp-content like so: wp-content/mygalleries/gal_a wp-content/mygalleries/gal_b ...
0
votes
2answers
137 views

Extract url from next_image_link

Is there a way to extract the url from next_image_link? I want the image on the attachment page to link to the next image, but i didn't manage to figure out how to do it.
0
votes
0answers
83 views

Some images not being returned with wp_get_attachment_image

For some reason this code works on my local copy of a wordpress site but the live site is not working. // WP_Query arguments $args = array ( 'post_type' => 'post', ...
0
votes
1answer
443 views

How do i save and retrieve custom attachment meta?

I'm trying to save if a checkbox inside of the media uploader pop up is checked, so i can retrieve it from the front end. I'm using this code: function filter_attachment_fields_to_edit( ...
0
votes
1answer
147 views

Count images in post then add class if just one

I'm trying to add a function to my site that will count the number of images attached to a post, and if only one, to add a class to either that <img> or to the containing <a>. I think I'm ...
0
votes
1answer
115 views

Weird string offset errors when displaying post attachments

I'm trying to create a gallery page that takes image attachments from a certain category and displays them. It works but I have a problem it seems where I'm trying to exclude certain attachment types ...
0
votes
1answer
40 views

Get post id by attachment id?

I have attachment id, but can't find way to get post id by this attachment id. I can loop all posts and find it, but maybe exists easy way get it. Does anyone know a similar function?
0
votes
1answer
70 views

How to get list of paths (not urls) for an image

I can get a list of urls for an image like this: $sizes = array_merge(array('full'),get_intermediate_image_sizes()); foreach ($sizes as $imageSize) { $image_attributes = ...
2
votes
1answer
199 views

Rename attachments during upload

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 ...
0
votes
0answers
32 views

How to store and retrieve the attachment alignment?

I am working on a project, where I want to display all image attachments of a post. Getting the URL and size of the images is not a problem, since both get stored in the database, if the image gets ...
2
votes
0answers
135 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 ...
0
votes
1answer
605 views

Get ID of first image attached to a post

I'm looking to find a solution that enables me to get the ID of the first image attached to a post in the loop. I'm currently using this; $size = 'post-thumbnail'; // Define image_size to be used ...
0
votes
1answer
54 views

500 internal error at wp_generate_attachment_metadata

I found that my PHP script throws an 500 (Internal Server Error) at the line which wp_generate_attachment_metadata function is used: $attach_data = wp_generate_attachment_metadata( $attach_id, ...
0
votes
1answer
69 views

Delete child post and attachment links to parent post

I have a hierarchical posts, when ever I delete the child posts its attachments go and link to deleted post's parent How can I stop this?
3
votes
2answers
544 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 ...
0
votes
3answers
238 views

Calling a javascript function in post edit page after attaching something to post

I would like to call a javascript function after user attaches something to post. I hooked the add_attachment hook, and processed what I want. However, how can I call a function in a Javascript loaded ...
2
votes
1answer
528 views

Change the Permalink for wordpress attachment

My attachments are currently rewritten from http://localhost/?attachment_id=3 to http://localhost/images/image-title using @Bainternet's answer here. $new_rules['images/(\d*)$'] = ...
0
votes
0answers
27 views

Change only the attachment permalinks to %post_id%

My permalinks are set to /%category%/%postname%/ but I would like attachments to live at photo/%post_id%/ I already have a rewrite function to change the attachment slug from attachment/ to photo/, ...
0
votes
0answers
109 views

Attaching images on frontend with AJAX to show thumbnails before submitting form

I currently have a frontend post upload form working so that users can add thumbnail attachments to a post, however it isn't possible to see which thumbnails you have attached before you submit the ...
0
votes
1answer
28 views

Check whether attachment ID is associated with more than one post?

Is there a function to check whether an attachment ID (=get_post_thumbnail_id(..)) is associated with more than one post? With "associated" I mean that a posts's meta value for the meta_key ...
0
votes
1answer
148 views

How can I return multiple image attachments with wp_get_attachment_image_src

I want to return multiple image attachments to my template landing page, but wp_get_attachment_image_src only returns the first image attachment. How come? Thanks in advance <?php /** ...
1
vote
1answer
210 views

Replacing all attachment links in post with media file link

I'm working on a Wordpress site, where all images inside posts are linking to the corresponding attachment pages. I want to use a lightbox but obviously this would require changing all the links back ...
2
votes
1answer
109 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. ...
3
votes
2answers
2k views

wp_generate_attachment_metadata gives me an empty array

I have a custom post type and a metabox with a file input. I can insert the attachment, but I can't update the attachment metadata and I don't know how to fix it because I don't receive any error. ...
0
votes
0answers
193 views

How to attach image to custom post type

I am using this answer to upload files in my custom post type meta box. How do I attach the actual attachment post to parent post(custom-post-type), so that in wordpress admin, I know that the image ...
1
vote
2answers
69 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 ...
4
votes
1answer
2k views

How to paginate wordpress [gallery] shortcode?

I am using wordpress gallery shortcode [gallery] I was wondering if there is anyway to paginate them without using a plugin.
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
545 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 ...
2
votes
2answers
2k 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
58 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
102 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
2k 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
251 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
79 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 ...