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
24 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
34 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
2answers
211 views

is it possible to force wordpress to always save thumbnails as 'jpg' not 'png'

I cant see any settings and cant see much in the php api docs regarding this? for instance if the original file upload is a png wordpress converts to jpg
0
votes
0answers
22 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
40 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 ...
1
vote
1answer
23 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 ...
3
votes
2answers
65 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
25 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
79 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 ...
2
votes
2answers
354 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
46 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
100 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
288 views

Upload unnattached image from frontend

I am using the below function to let users upload files from the front end. It works great except that I would like the file to NOT be attached to any post. Currently, the file is automatically ...
0
votes
0answers
16 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
69 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
1answer
33 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
89 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
0answers
29 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
7 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
26 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
78 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 ...
0
votes
1answer
2k views

How to create an attachments archive with working pagination?

This might sound like query_posts with pagination problem number 2103024 but I think this one might be special. My WordPress site is basically a huge database of car images. Each image should have ...
0
votes
0answers
35 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
19 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
1answer
60 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 ...
0
votes
2answers
62 views

Show title when inserting single images

I just can't get how to do this. When inserting a gallery I have this output: <a href="path_to_files/image.jpg" title="fancy title"> <img width="150" height="150" ...
1
vote
1answer
1k 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 ...
0
votes
1answer
573 views

How to get meta value in wp_attachment_metadata

I want to get wp_attachment_metadata in my own way. I want to separate the sizes (Thumbnail, Large, Medium, Small). The meta value on database looks like this: ...
2
votes
1answer
22 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
106 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
41 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 ...
1
vote
2answers
38 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
44 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). ...
2
votes
1answer
1k views

How to remove title attribute from gallery links and images

I want to remove the title attribute from within the output of a [gallery] shortcode e.g. <a href="url" title="bobby"> <img src="url" title="bobby"/> </a> should be: ...
0
votes
0answers
91 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
31 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
0answers
124 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
1answer
37 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
150 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
154 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
2answers
1k views

ID of images from gallery

Does anyone know how to get ID's of images from wordpress gallery in post? I have search entire internet and there is nothing to this subject.
0
votes
0answers
95 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
68 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 ...
3
votes
2answers
2k views

Correctly delete posts with meta and attachments [duplicate]

I am having an overview of custom post types. These have custom tax and also an attachment. In my overview I need to provide links to delete the entries. With that I also need to delete the ...
6
votes
2answers
8k views

Get all image from single page using this query

I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the ...
0
votes
1answer
75 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
75 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 ...
2
votes
1answer
417 views

How to grab the first two image attachments from a post?

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, ...
0
votes
1answer
75 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
24 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 ...