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

Removing options from attachment details

In the image gallery section of my Wordpress admin, when I click on an image I get something like this: My site allows multiple users to add images and I feel that most of these fields are ...
0
votes
2answers
15 views

Adding metaboxes to attachment pages

My script cannot save the value of the dropdown box. I could not find any helpful documentation on this topic, so I have decided to ask the StackExchange community about it. function ...
1
vote
1answer
1k views

Ordering of gallery images without using shortcode in theme

I using the built-in gallery in wordpress to store and sort images inside a custom post type. In the theme I was using: $attachments = get_posts( array('post_type' => 'attachment',...
3
votes
1answer
124 views

Post being redirected to attachment post

That's strange issue I have on this one website. Similar to this problem and I am trying to get this fixed from last couple of weeks. This website have latest WordPress installed and /%postname%/ ...
0
votes
1answer
300 views

Get attachment file link

I'm building a theme that generates on the home template a link to the PDF attached to the post (it will be only PDF files). I found a solution to check if the post has a PDF attached. The goal is to ...
0
votes
1answer
2k 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: a:5:{s:5:"width";i:660;s:6:"height";i:...
4
votes
2answers
485 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 ...
0
votes
0answers
574 views

How to configure Dropzone.js to work with Wordpress media attachments

I have built a site that has a public front end which shows off profile pages for cars. I have built a members only back end which allows people to create accounts, and then make a profile page for ...
0
votes
0answers
25 views

Thumbnails and active class on single attachment template

I'm building a flickr like gallery where: I have a post with Image gallery thumbnail After clicking on a thumbnail, I go to the single attachment template (image.php) and display a full image. In ...
0
votes
1answer
29 views

When inserting attachments into a blog post, how can I get Wordpress to use the full filename with the extension?

I'm using WordPress as a way to keep track of several different types of data which all have different extension names -- file1.fig, file2.dat, etc. When I upload a file and insert it into a blog ...
0
votes
0answers
74 views

add_attachment in not working with wp_get_attachment_image_src

This code is not working add_action('add_attachment', 'example_file_added'); function example_file_added( $attachment_id ) { $attachments = wp_get_attachment_image_src($attachment_id,"medium"); ...
2
votes
1answer
179 views

Can I disable this core query?

When a user creates/updates a post within the admin, it takes between 15 and 30 seconds for that operation to complete. The culprit appears to be this slow query: SELECT ID FROM wp_posts WHERE ...
1
vote
3answers
3k views

Image still linked as attachment to page even though it has been deleted

I have been working on an image gallery feature where I grab images which are attached to pages and display them in various places via the get_posts() function. However, I am finding that when I ...
0
votes
0answers
83 views

How could I add button next to “edit image” button in “Attachment Details”

How could I add button next to "edit image" button in "Attachment Details" This is the location I would like to add button, Do you have any recommend?
1
vote
1answer
219 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. http://...
0
votes
0answers
48 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
314 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
2answers
86 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
2answers
536 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 ...
18
votes
4answers
20k 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
124 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
217 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
172 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
100 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 ...
0
votes
0answers
31 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
10 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.
3
votes
0answers
49 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, ...
3
votes
1answer
51 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
194 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
843 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
14 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 images'...
1
vote
1answer
99 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
131 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
5k 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
131 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
670 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 ...
5
votes
2answers
5k 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 ...
1
vote
1answer
89 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 ...
3
votes
3answers
6k 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 = "http://www.tumblr....
0
votes
1answer
166 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 ...
1
vote
1answer
400 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
4k 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
1k 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 for="imgdesc[]"&...
4
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 ...
0
votes
2answers
246 views

All attachment pages give 404

I have a major issue with wordpress on my new website. Anytime I upload a new media, its attachment page gives me a 404. My permalink structure is the following: baseurl + /%category%/%year%/%...
2
votes
1answer
123 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
720 views

get_attached_media() returns empty array if media file already used by another post

I wish to retrieve the different PDF and ZIP files attached to a single post and display them in a specific section, outside the content, using the WP function get_attached_media(). While my code ...
0
votes
3answers
112 views

wp_query get attachments in larger size

I'm using wp_query to get all attachments, and it works, but I wonder how could I get attachments in full size because this query returns images in medium. <?php $args = array('post_status' =&...
1
vote
1answer
1k views

Get attachments by user

Is there a way to get attachments by user? I need a way to display all the images uploaded by a specific user. (I probably need the attachment IDs so that I can use wp_get_attachment_url to display ...
0
votes
1answer
115 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: ...