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
5 views

Automatic category assignment upon attachment upload

Lets say the media library has the following category [news, events, photo, page, post] Your wordpress also has the above 5 set as post-type. What I want is when 1- Events -> Add New 2- File is ...
1
vote
0answers
25 views

How to trigger a refresh in the media modal

I'm developing a plugin that adds a new tab to the media modal, and I need to know a way trigger a refresh of the attachments tab so it shows newly added attachments. This is the code I'm using: ...
4
votes
3answers
77 views

Stop WordPress from reserving slugs for media items?

I am experiencing some odd behavior, that apparently happens "out of the box" with WordPress. If I upload a file through the media manager called: services.jpg; then go try to create a page with the ...
0
votes
0answers
19 views

How to get blog id of a post from admin panel?

I have multi-site and using add_attachment($post_id) hook to get the $post_id whenever a binary file is uploaded. I need to figure out the $blog_id of that post. How would I go about doing this? I ...
0
votes
0answers
15 views

Automatically attach image to post if they have the same title

I have 200 images in my WP install. Currently, each image... has its own post (the post title is the same as the image title) is the featured image of that post is inserted into the post ...
0
votes
1answer
24 views

How do you import images from a URL in your post?

I am looking to automatically set the featured image from a URL, I have a plugin that creates new posts and has a link back to the source website, I would like to be able to scrape that link for an ...
0
votes
0answers
12 views

Prevent attachment from being deleted

In Wordpress admin media library page (upload.php) I'd like to do some checking on delete_attachment action. I want my custom function to fire before attachment's being deleted. In this function I ...
0
votes
1answer
23 views

Get Image tag from content of post

I have create a custom sidebar, and want to show only posts images in that sidebar. I have add a post with some text and choose image from gallery in the content of that post. Now i want to get only ...
3
votes
2answers
45 views

Audio or playlist shortcode condition according to the amount of files on attachment page

My reason for doing this is for a music & entertainment site where users will have the ability to share music and videos on other websites via embed code. I'm using the audio.php and video.php ...
0
votes
0answers
19 views

Include attachments with a custom taxonomy in search

I need to include attachments in the search. So far, I have managed this by hooking into pre_get_posts and checking if it's on the search results page, I add 'attachment' to the post_type and ...
0
votes
0answers
38 views

File path for attachments outside of wp-content/uploads

I am creating some custom post creation pages with PHP. I create a simple post and want to attach an image I already have on my server to the post without moving it into the upload directory. I am ...
1
vote
1answer
15 views

post_parent is 0 when uploading new files

I have a custom-type post I'm trying to attach some audio/wav files to using the wp-admin UI. When I upload the new files using the Add Media popup those get saved and embedded into the post just ...
0
votes
0answers
14 views

Set featured image using wp_insert_post

// Auto post ( Unique File Date ). $postData = array( 'post_category' => array( $Category ), 'post_status' => $Post_Status, ...
2
votes
2answers
98 views

Delivering a file instead of wordpress page

I'm trying to make a page where a user provides an ID of a attachment and the site will set the headers and deliver that file instead of a 404 page. so /download/1754 would lookup the attachment with ...
0
votes
1answer
23 views

How to retrieve images attached to post through media library?

I have been struggling to retrieve image attachments to specific post without success until I found that images inserted into the post via media library are not treated as attachments. That is, you ...
0
votes
1answer
48 views

i'm trying to get all my media query attachments via ajax in wordpress

i'm trying to load all my media files via ajax: $.ajax({ url: '/wp-admin/admin-ajax.php', type: 'post', data: { 'action': 'query-attachments', 'post_id': 0, ...
0
votes
1answer
34 views

How can I change wordpress attachment url and protect it?

I was confused by one thing, because Wordpress attachment url is directly to see and for download, I want to hidden it and make it transfer by one file so I can add some control for this file. now I ...
0
votes
0answers
17 views

Issue on Getting WP Gallery Items In cpt-single.php As Attachments

Having a "Custom Post Type" called Projects I am trying to get actual URL of images added into Post Gallery and list them in class other than WordPress built in .gallery. This is the code which I ...
0
votes
0answers
5 views

Prevent Wordpress from creating an image post

Some of my sites depend on a lot of images - usually very small images. I want to disable the Wordpress feature which creates a post for every media file uploaded on the site. I checked my site ...
0
votes
0answers
16 views

Change categories count to include media attachments

I am creating a gallery that will automatically display new images from a chosen category and its subcategories. I have set up the categories so that they will apply to media using: ...
0
votes
1answer
31 views

getting attachement images src and add classes

I have posts whose each contains 4 attached images. what i'm trying to do in my single.php is to get all the 4 images src to be abble to add different classes to each images. <img class="image_1 ...
2
votes
2answers
191 views

Add custom field to media attachment image attribute in post editor

I have the following filter, but do not know how to add custom attributes to image field, when attaching media to post. example <img data-ext-link-title="" data-ext-link-url=""> ...
0
votes
0answers
28 views

Image URL clashing with Page URL

I have been using the same structure on this site for a long time and it has never been a problem, so I'm not sure why it has become a problem now: If I have a page URL www.example.com/sedan-cars/ I ...
0
votes
0answers
13 views

Batch Rename Images

I know how to do this during upload, but what about after the fact. Is there an easier way then what I'm doing to rename images? I'm using php rename function for the image itself, but what about ...
0
votes
0answers
11 views

Attachments doesn't update

I did use wp_attachments to display images from posts by url. With that in functions.php 'function twentythirteen_the_attached_image() { $post = get_post(); $attachment_size = ...
0
votes
1answer
40 views

Get images from the post

Using Add Media I am inserting images in the Post.I want to reterive these only these images on the single post page.I am using get_attached_media function to reterive these images.But it returns an ...
2
votes
1answer
19 views

Confused with attachment mimetype order

Suppose I have attachments of MIME type image/png, image/jpeg and image/gif. And I have template files image.php and gif.php in my theme folder. So, this means that I want to customize a page ...
0
votes
0answers
85 views

Show prev and next post links for parent post of current image in attachment page?

I use this code to show previous and next posts (in same category) on post pages (single.php). <?php $next_post = get_next_post(TRUE); // TRUE = in same category if (!empty( $next_post )): ?> ...
0
votes
1answer
28 views

Check if parent post is sticky on attachment page?

I use this code on post template (single.php) to check if current post is sticky: <?php if ( is_sticky() ) echo 'Post is sticky.'; ?> But it is not working on attachment page template ...
0
votes
2answers
18 views

Show post tags on attachment page?

I use this code to show post tag(s) on single.php template: <?php the_tags('<div>Tagged with:<br> ',' | ','</div>');?> I wish to display post tags on attachment page too, ...
0
votes
1answer
26 views

Show custom field on attachment page?

I use this code to show custom field value outside loop on post page (single.php): <?php echo get_custom_field('my_custom_field'); ?> But, that is not working on attachment page (image.php). ...
0
votes
0answers
64 views

Changing attachment url?

How to change default attachment url: www.domain.com/category-name/subcategory-name/some-post-title-here/attachment/some-post-title to: ...
0
votes
1answer
95 views

Insert Media - Attachment - Link to : Remove the “attachment page” option

I want to remove the attachment page option from the attachment's link-to selection. I don't always want to tell my clients to avoid selecting this option, I simply want to take it out. But I am not ...
0
votes
1answer
29 views

How to link images to attachment.php [duplicate]

I have custom attachment.php, I want to give link for images in single.php so if user click that images, will redirect to attachment.php is that possible? Here is the example of code. <a ...
0
votes
1answer
30 views

List attachments of a page

I need to generate a list of attachments uploaded to a specific page (id=628). I thought this code was going to work, but it doesn't generate anything at all: <?php get_header(); ?> <div ...
0
votes
0answers
92 views

Get attachment post id to display attachment custom field data

I have created a custom field for attachment images, for a custom post type, using the extremely helpful tutorial on the process by Andy Blackwell employing the attachment_fields_to_edit and ...
4
votes
2answers
86 views

Check if post has attachments (not image)

Need to do a check if post has attachments that are not images. I haven't seen this anywhere - thoughts?
0
votes
0answers
78 views

Change default URL of image attachment

I have only one image attachment per post, as featured image. Every post have just one image, featured image, and no any other image in post content. By default URL of image attachment is: ...
0
votes
0answers
53 views

How to add jQuery div element to each image on wp site?

I'm trying to add the "Share" button to each of the attachments inside of the post. I found function that allows to get all attachments on the post: ...
0
votes
1answer
41 views

How to update the title of audio file through its attachment metadata

I am trying to programmatically update some metadata of audio file attached to a post. I have been able to update the artist and album properties of the audio file but title doesn't stick. I can go ...
0
votes
1answer
52 views

How do I create Comma Separated list of attached image ids?

I'm trying to grab the image id's of attached images to a post. I'm using an example posted here, but am having trouble returning the just the ids and not the entire array. My goal is to return a ...
0
votes
1answer
55 views

WP_Query for attachments without duplicating post_parent and displaying tagged image

I've tagged a number of media uploads on my site with the various products' names which are featured in them. The goal is to get a list of the posts which have been tagged with each product name, but ...
0
votes
1answer
48 views

What's the database relationship between a post and its attachments

I'm creating a custom import script to migrate CSV data into wordpress. Each post has a series of attachments that must come with it. Following chapter 14 (importing via a custom mysql script) in the ...
0
votes
0answers
18 views

What should the WXR look like when importing non Wordpress content and related images into wordpress?

I'm migrating data from a static website into wordpress. The data from the static websites has been scraped and included in a CSV file along with urls to the links that represent the photos for the ...
0
votes
0answers
8 views

Deactivate url on attachment item

I have a little question for you.. On my website, in the last step when the image from attachment it's on the big size, i want to remove the link from it because on click redirect the visitator to ...
0
votes
0answers
10 views

only first caption showing for attachment in Wordpress

ok I'm using the below code to generate caption for my attachments. The problem is if I have multiple images in a single page, the caption for first image shows for all the images. like if I have ...
1
vote
1answer
50 views

Display attachment resolution size

Seems rather easy, but there is no article I can find on the web or in Wordpress about it. How to simply display (in the current post) the full image size (of the attachment), in pixels? thank you
0
votes
0answers
138 views

How do I get attachment_id?

This is trivial, but I can't really find an answer, I've seen some hints like search in database etc., but this is madness. Basically, I have a metabox with upload button that allows you to upload or ...
0
votes
1answer
176 views

Making images from single.php pointing to an attachment .php template

I am trying to make the inserted images from a post (single.php) to point to (single-attachement.php) an attachment page. So far I checked a post here on stackexchange and added this code on the top, ...
0
votes
0answers
22 views

Bad attachment links (starting with “../wp-content/uploads”)

For some reason, WordPress is generating attachment images with bad links (beginning with a relative call, which breaks with prettified URLs). The links begin with "../wp-content" - and I can't figure ...