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

5
votes
2answers
206 views

Is it possible to query all posts that don't have an attachment?

I want to get a list of all posts that don't have an attachment and delete them. This question takes about getting all posts that have an attachment, but I want the reverse of it. The brute force ...
0
votes
0answers
20 views

Remove attached media

I've created a custom Page Template that grabs all the attached media (images) to the page using get_attached_media(). I'm adding the media by clicking on Add Media button above page title. If I ...
1
vote
1answer
28 views

Show attached media image if no thumbnail image detected

I use the if ( has_post_thumbnail() ){} to check if the post have thumbnail image, but this echo get_attached_media('image', $post->ID); displays the word Array I need to show the ...
1
vote
2answers
27 views

How to add a rel attribute to images that contains their categories?

I've added categories to images, so that I can use them to filter images within a portfolio page. Now I'm thinking I need to add the rel attribute to each image that contains its assigned categories. ...
0
votes
0answers
15 views

All post attachments in gallery grid to full screen slideshow?

Using the default wp gallery for displaying the attachments. All attachments for the specific post in full screen slideshow when click on image. I am using also Bootstrap frond end framework. Possible ...
0
votes
1answer
9 views

Differentiate attachment pages in search results

I'm using the Relevanssi search plugin, which is basically a better version of the default search. Anyway when I search for something it displays everything I need it to, I was just wondering whether ...
0
votes
0answers
20 views

Display further content in file media attachment

When i see the image attachment in full size I need to show text in wp-content/uploads/2014/08/filename.jpg. Also I need to show go back button, and others info about the image opened in full size. I ...
0
votes
0answers
5 views

I want to display tag description and tagged attachment (without post if there isn't..) while using tag url

I am new to coding, but i do understand a little bit. Is there a way to edit tag.php to achieve this? I have added Shiba media library plugin to my site so that i can add tags and catagories to ...
0
votes
1answer
29 views

attachment.php & flexslider—linking thumbnail to specific image

I am nearly there but need the help of the community to bring me home! I am linking from a "gallery overview" page (thumbnail grid) to a single, full-size image page (attachment.php) containing a ...
0
votes
0answers
21 views

Attachment doesn't display post_parent gallery in multisite

I am working on multisite in a subfolder. I create a post with image linked to "attachment page" and not to a "media file". If the post has one single attachment and if i click to this image ...
0
votes
0answers
11 views

Image path in posts (/uploads/yyyy/mm) does not match actual file location

I just moved to a new server and upgraded WordPress as well. Somewhere in the process my image paths in old posts got mismatched to the actual file location. All the old images are now broken. As an ...
3
votes
1answer
61 views

How to add classes to images based on their categories?

I need to be able to: 1.) assign categories to images and 2.) add classes to all images that correspond to their assigned categories. I was able to add categories to images with the following: ...
0
votes
0answers
15 views

Native WordPress Media Uploader on WordPress Frontend

I am using a custom template on my site to enable frontend posting. I wanted to add an option to upload media(such as pictures) on this form exactly the way native WordPress backend has. In short I ...
0
votes
2answers
13 views

How to prevent people from seeing an attachment to a scheduled post that's released in future?

I'm developing a website for a large corporation. They release financial documents on specific dates and times. I've developed a custom form to upload these pdfs to articles, and custom loops that ...
1
vote
1answer
46 views

How to add a class to the attachment images

When I'm in the Wordpress editor and I add an external image with the 'img' button, my html result wil be like this: <img src="http://example.com/image.jpg" alt="image" /> How can ...
4
votes
2answers
90 views

Unattaching unlinked images

As I understand default WP behavior: When you upload an image to a post and save it (as a draft or published post), the image becomes "attached" to the post. This can be double checked by going to ...
0
votes
0answers
12 views

Rewrites and Attachments

I'm currently working on a custom post type that has rewrite tags to allow for sub pages. e.g: showcases/project-name/media/ Media being the page. My problem is with attachments and media uploads, ...
0
votes
1answer
28 views

Create a custom attachment thumbnail for quick page load

I've been trying to find a way to create a custom image attachment thumbnail. I want to display an image attachment thumb and link to the full size. (FYI The thumb is to get quick page loading speed ...
4
votes
2answers
99 views

Get all posts (of any post type) an attachment is used in

It's not easy to count the amount of posts an image is attached to - WordPress simply doesn't keep track of that. It just keeps track of the post an attachment was originally uploaded to (not ...
1
vote
0answers
12 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 ...
0
votes
1answer
22 views

Surround uploaded image link with div

When you upload image you have smth like this <a href="http://vitya/wp-content/uploads/2014/06/8.jpg"> <img class="alignnone size-Small x Big wp-image-65" ...
0
votes
0answers
9 views

How to change the structure of an image attachment in a post?

I'm trying to solve a problem with the attached images in a post. Somehow the structure is not working right on a theme i'm using. Instead of showing a div with the class "wp_attachment" is just a h6 ...
1
vote
1answer
97 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 ...
0
votes
2answers
53 views

How to check if there is image title, caption, description?

I use this code to display featured image title, caption (excerpt), description (content): echo get_post(get_post_thumbnail_id())->post_title; echo ...
0
votes
1answer
123 views

Get the size (size in Kb or MB) of an featured image?

I need to display some featured image info on post page. Among other info I need to display file size of image (featured image of post). I tried this function inside single.php. <?php function ...
0
votes
0answers
7 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
1answer
44 views

How to change image url?

How can I change the image url from this http://i0.wp.com/example.com/wp-content/uploads/2014/06/imagename Into this: http://www.example.com/image/imagename.jpg Or into this: ...
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
103 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
38 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
0answers
59 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
0answers
43 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
1answer
57 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 ...
0
votes
0answers
12 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
14 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
26 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 ...
0
votes
1answer
65 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
30 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
14 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
97 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
63 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
65 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
53 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
34 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
51 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 = ...
0
votes
0answers
24 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
122 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
206 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
34 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
139 views

Is it important to get the media files attached?

A silly question may be, but I's thinking about the SEO matter, and thinking that, is there anything related to the SEO regarding the Media file attachment? There are 567 images in my Media Library, ...