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
1answer
13 views

Getting “too many redirects” when using wp_redirect for attachment page

Code comes from the codex: <?php wp_redirect( get_permalink( $post->post_parent )); exit; ?> I added the above, in an empty attachment.php page. When I visit an attachment page (eg. ...
0
votes
0answers
5 views

Delete duplicate media in SQL only

I have uninstalled WPML and deleted all WPML tables in the DB. Now, I have duplicate media (one per old languages) in my SQL only (not in the FTP). I would like to delete these duplicates and only ...
0
votes
1answer
17 views

how to get attached file url for current post?

Trying to get the attachment file url for current post, using this code: if ( is_singular('post') ) { $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post_status' => ...
1
vote
1answer
460 views

How to retrieve attachments from child pages of a specific Page?

How would I retrieve attachments from all subpages of a specific Page ID? Example: SPECIFIC PAGE Child (with attachments) Child (with attachments) Child (with attachments) I'm currently ...
1
vote
2answers
31 views

shortcode get thumbnail size

How to get shortcode thumbnail size? my code get shortcode thumbnail size in functions: function thumb_medium( $atts, $content = null ) { return wp_get_attachment_url( get_post_thumbnail_id( ...
0
votes
1answer
2k views

Let users upload image(s) to the post from front end

I want to enable logged in users (Wordpress) to submit posts from front end (among with other data). My form is working great, I add custom post meta data which I later display on custom post page. ...
4
votes
3answers
640 views

List most recent image uploads, but only for specific custom post type

I can get a list of the most recent image attachments like so: $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => $number, 'post_mime_type' => ...
0
votes
1answer
357 views

How to allow specific extensions and file size to wp_mail attachment?

I am trying to create a form with an attachment option that will be sent to an email when the form is submitted on a wordpress site. My codes work fine and it sends email in a HTMKL table format to ...
0
votes
2answers
383 views

Show selected images on top in Media Manager

I've searched numerous StackOverflow and Wordpress Awnsers questions, but I couldn't find any solution that matches my situation or even remotely points me in the right direction. I have a custom ...
15
votes
4answers
15k views

How do I get the size of an attachment file?

I'm using the following template code to display attachment links: $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => ...
0
votes
1answer
664 views

Get all attachments by custom taxonomy - term

I want to make custom taxonomy (gallery) and terms (name1, name2, name3...) Add images into media tab and then retrieve all images from same term. Look like simple task, but I cant manage it. I ...
1
vote
2answers
412 views

Moving image attachment from post to another?

How to move image attachment from post to another (not to "Remove Permanently" and Re-Upload) ? I'm using WordPress 3.5.0 and I have a thousand images to process. Is there a built-in function for ...
0
votes
1answer
39 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
192 views

Add audio attachment link to RSS

This is how I'm adding a featured image to my RSS: function featuredtoRSS($content) { global $post; if ( has_post_thumbnail( $post->ID ) ){ $content = '' . get_the_post_thumbnail( $post->ID, ...
0
votes
2answers
757 views

How to get thumbnail from post attachment in this loop

I use this code to display Most popular posts based on view count, but I dont have images in post content I have all images attached to post via attachment (gallery) How to replace this "thimthumb" ...
0
votes
2answers
2k views

Why can I not view image attachment pages?

I have a problem with images. I can see my uploaded images, as previously, through the media library. I can access each image by clicking on "edit". But if I then click on "View Attachment Page", I ...
0
votes
2answers
555 views

Attach images to posts using custom fields (just paths to images already upld)

I'm setting up a real estate website, which i make listings using a custom post type 'listings' in which I have multiples metaboxes for beds, baths, and all other informations. I use a plugin to ...
0
votes
2answers
99 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
0answers
21 views

Attach Gravity Form File Upload to Custom Page and Set Image Title & Description from Form Fields

I have a Gravity Form with fields for name, city and file upload. I would like the file uploaded to a) get attached to a specific page (not the page with the form) and b) have the image's title & ...
0
votes
1answer
416 views

save_post not working with attachments

I've made a Meta Box for Posts and Pages, and while testing added Attachments too. But, curiously, the hook save_post does not fire. $cpts = apply_filters( 'my_filter', array( 'post', 'page' ) ); // ...
1
vote
0answers
12 views

How to change the attached image's name after save post? [on hold]

I would like to let the user upload images with any name, and automatically modify their name to the format as %post_id%-01, %post_id%-02, %post_id%-03... when save post. And I'm using the plugin ...
0
votes
0answers
23 views

Get Previous & Next Attachment Links (With Thumbnails)

I'm building a theme that explicitly displays an attachment on a single page (not using attachment.php at this time, but the idea is the same). I have the 'attachment_id' value, and the attachment ...
1
vote
1answer
386 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
673 views

Load post attached images on a single page site with fancybox

I'm trying to make a single page site that will display posts as thumbnails in some part. Then if a thumbnail is clicked, I want all the images contained in this post to be loaded with fancybox while ...
0
votes
0answers
9 views

get_children() show deleted attachments of the post

I have a problem with the attachments in a post :( If I upload an image into a post and after I delete it, Wordpress show the image as still attached to that post. This is my code to retrive the ...
0
votes
0answers
4 views

Gallery attached to a post but outside it (my-post-url/my-gallery)

I want to create a post gallery related to a WordPress post, but outside it, for example: my-post-url -> Display my post. my-post-url/gallery -> Display my galelry.
2
votes
0answers
16 views

Custom collection in media manager?

I'm working on a plugin that extends the media manager, load JSON based input data to render an own collection of images and may upload them to my wordpress media library. So far I got my own tab, ...
2
votes
1answer
16 views

Add column for attachment file size

EDIT. I got this working, see my own answer below: Now, if someone has any clue as to how I can get this sortable, please chime in! :) ---------------- Original question ---------------- How can I ...
0
votes
0answers
36 views

Get video attachment ID and display length

I need to show length of a video attachment. Video is in media library. I put the video normally, by wp administration. I am using this code in content.php, inside the loop, after this: <?php ...
1
vote
2answers
590 views

Disable edit media attachments?

Looking for a way to disable the "Edit Image" option. I would still like to be able to edit the description, alt, etc. But remove the Edit image button or disable that image editor. Thanks,
0
votes
0answers
11 views

Stop images from being displayed on the front-end of the site

I run a store with woocommerce on Wordpress, however there is an image called 'basket.png', and for some reason it has taken the link /basket on the site. Is there a way to disable all of the ...
1
vote
1answer
42 views

Do attachments added to custom post types have a post parent?

On attachment pages, I have a link back to the post/page where the file was uploaded. (This is not displayed for files that were directly added to the Media Library and that's fine.) For attachments ...
0
votes
1answer
41 views

Prevent image from being accessible via url as a post?

I've noticed that if I upload an image to the media library it is given a post_name in the database and is then accessible via mysite.com/wordpress/its-post_name. It only seems to do it if I upload it ...
1
vote
1answer
3k views

How to solve: An error occured in the upload

This error message appears when I try to upload any picture. Currently I am using WordPress 3.8.
1
vote
0answers
29 views

Attachment page gives 404 if user not logged

I am struggling on a very weird behaviour for a WP site I have developed. My client have uploaded many photos to the media library, and tags them with some custom taxonomies I have defined. Some of ...
1
vote
1answer
400 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 ...
4
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 ...
0
votes
0answers
17 views

Changing attachment status from inherit to pending?

I'm creating a web library that consists of about 1,000 PDF files uploaded as attachments (in addition to pages and posts which contain other information). I've bypassed the attach-to-a-page/post ...
3
votes
2answers
1k views

remove missing image attachments

Best way to programatically remove attachments that are missing images? I ask because after using a caching plugin, I have images that have been input in the database as attachments that don't ...
0
votes
0answers
46 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 ...
1
vote
1answer
52 views

Massive photogallery import

I have this scenario: about 200 photo galleries to recreate in Wordpress from an old wordpress site. All I have is the .xml WXR for the post_type "photogallery" that basically creates the gallery and ...
0
votes
0answers
13 views

Checkbox group on attachments page

I am trying to add check boxes on media page depending upon no of roles in the system and I have been able to do that like this. function add_custom_attachment_fields($form_fields, $post){ ...
4
votes
2answers
190 views

What is the different between an attachment in wp_posts and an attachment in wp_postmeta?

After the Woocommerce dummy products are imported, I notice that in the database, there are different records in different tables but point to THE SAME photo attachment. The question is why? What are ...
3
votes
3answers
5k views

How to find attachment ID for first image in a post

I am using a plugin to forward photo posts from wordpress to a tumblr blog. I have the following code: //post blog to tumblr function postBlogTumblr($postID) { $URLServer = ...
0
votes
1answer
36 views

missing attachment are showing as 404

In Google WebMaster Tools the crawling errors page is showing 177 missing urls. Most of them are showing as ?attachment_id=xxx I have looked in the database for these id's in the wp_posts table but ...
0
votes
0answers
15 views

Update wp.media state (mainly order) of images in Add Media Modal

I have to mimic a feature that was part of Wordpress 3.5 but was removed in Wordpress 4.0. When I am seeing the files uploaded to a post in the Add Media Modal, if I chose "Uploaded to this post", I ...
1
vote
1answer
359 views

How to remove parent section from attachment URL?

I have buddypress installed. All URL goes under BP's URL structure. If an attachment belongs to a document in a group, the URL is: http://domain.com/groups/group-name/docs/doc-name/attachment-name ...
0
votes
1answer
85 views

How to get image title/alt attribute?

in my wite theme, there is no alt tag configured in home slider post, i have added alt text with image from media upload. i have added below code to add / retrieve alt tag. but it display blank ...
0
votes
1answer
138 views

Upload multiple image with media_handle_upload with multiple file field [duplicate]

I need to add multiple images with image descriptions form wp admin. Admin Form: <label for="image[]">Image</label> <input type="file" name="image[]"/> <label ...
3
votes
4answers
5k views

Applying automatic link class to images embedded to posts

I'd really love to be able to conditionally apply a CSS class to link elements of images embedded into posts, but I can't seem to figure this one out. Basically what I'd like to achieve is to replace ...