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

1
vote
1answer
45 views

Attach previously uploaded image to post - current code has unexpected results

What code currently does: I feed post id & previously uploaded image id, code processes it all and does its magic described below. Result: unattached old image and new attached image. What I ...
0
votes
0answers
19 views

Image upload on theme option page

I've found this script for adding some theme options in wordpress. add_action( 'admin_init', 'theme_options_init' ); add_action( 'admin_menu', 'theme_options_add_page' ); function ...
0
votes
0answers
23 views

Can't Change post_name from the following code

I am attaching my custom uploads through the following code and I am trying to change the post_name during upload. But its still keeps the file name instead of my custom title. function ...
3
votes
3answers
501 views

How do I exclude all images from a wp_query?

I want to query attachments and exclude all images. I can see how to include only images, using 'post_mime_type' => 'image/*', but I couldn't find any way of achieving the opposite. Is there any ...
1
vote
2answers
34 views

How to compress image before inserting to wordpress using wp_insert_attachment function?

Is it possible that when user submit multipart form for creating a new post in wordpress, all the images are inserted using wp_insert_attachment() to media library with compression so the uploading ...
0
votes
1answer
79 views

Removing delete permanently button in uploading files media

How do I delete or remove the word Delete Permanently in uploading files? I wanted to remove this permanently so that the users won't keep deleting files which are not supposed to delete. I use ...
0
votes
0answers
57 views

Insert image caption (metadata) in shortcode in functions.php

I've created a shortcode that displays a random image given that certain parameters are filled, like img url and number of images to random through. It looks like this: function randimg_shortcode( ...
0
votes
1answer
36 views

How to test if there are no more previous or next image on attachment page?

I have a next_image_link and previous_image_link as a navigation on my image.php but I want the first and last image to echo greyed out text (disabled button) to show prev button and next button. ...
0
votes
0answers
11 views

Custom Contact Form - Attachement and receivers

I have created a custom contact form using this code: function contact_form_markup() { $form_action = get_permalink(); $author_default = $_COOKIE['comment_author_'.COOKIEHASH]; $email_default ...
0
votes
1answer
39 views

Query All Attachments and Order by Parent Publish Date

I'm working on a project where I need to query all of the image attachments and then organize them based on the date the post they were attached to was published. The query below worked well, except ...
0
votes
0answers
74 views

Upload Multiple image attachments and save their IDs in custom meta fields from Front-End

Need some help on this one. I'm trying to upload multiple image attachments via Front-End and save their IDs in custom fields. Right now only the first image gets saved as custom field ...
0
votes
0answers
13 views

Restricted Attachments/Change Attachment Upload Location

I need a way to have certain post attachments (images/pdfs/etc) be restricted to specific logged in users. What is the best way to do this? At a high level it seem like I need to do the following: ...
0
votes
1answer
48 views

How To Query All Attachment Images Found In Post Galleries

I'm trying to create an image gallery which is comprised of all of the images attached to posts. The query below works well, but it ends up with all attached images rather than just the images ...
0
votes
1answer
53 views

wp_generate_attachment_metadata for non-images files

I created a frontend form for upload images and worked fine. The only problem is that I need generate attachment metadata for non images file. Now, metadata is only created for images files. I'm ...
0
votes
1answer
15 views

Echo list attachment size in post

i have a post width 10 attachment image in post i want querylist 10 attachment in post as: <li><a href="url-img-attachment-sizefull-img1" title=""><img ...
0
votes
0answers
63 views

Create a Gallery and update Post Parent of Attachment Images

I need to create a gallery for a custom-post and update the post_patent of every image with the new gallery ID function create_tfuse_gallery_group($post_id) { if ( get_post_type( $post_id ) == ...
0
votes
1answer
19 views

Is there a way to get attachment data?

So, I'm no big fan of how WP stores images (image data) and I was hoping there had been made some improvements in version 4.x. But alas no. When I say image data, I mean url, title, caption, alt ...
0
votes
2answers
40 views

How do I intercept and modify the functionality of wp_get_attachment_image()?

I have a site I'm building in wordpress that has ~80GB of high resolution images, and it's exceeding my managed host's storage space. My plan is to move all the images to S3, but I noticed that ...
3
votes
1answer
195 views

How do I detach images from posts?

Firstly I've seen some topics like this, but they haven't helped me. I've attached some images to a post via "Add Media" : And for showing these attached images, I used following code in ...
0
votes
1answer
22 views

Retrieve ONLY mp3s and set a variable for use in a playlist called by single.php template?

I'm trying to stuff a variable called $work_ids with the ID of any attached MP3 files for use in a custom player (based on MediaElement.js if that matters). The library contains WAV and other versions ...
0
votes
1answer
39 views

Show last 12 uploaded images on home page, but only from posts

I want to show the last 12 images that were published with articles on my front page. This is the code to get the latest 12 uploaded images, but i want to show only the ones attached to a post ...
0
votes
0answers
21 views

Is there a function like “attachment_fields_to_edit” but for “replacing” the image?

With the "attachment_fields_to_edit" function i can put custom fields to the images when i insert them in a post. The problem is, when someone clicks on "replace" he gets the "replace image" window ...
1
vote
0answers
20 views

Query to only return the 2 newest post attachments (images)?

How can you make a query that runs through all posts in a category and outputs only the 2 newest image attachments (most posts in the category have no attachments)? My current query is like this: ...
0
votes
0answers
36 views

How to ensure all image attachment page urls are using the filename and not the title?

I noticed something strange. On just a couple of posts, where the title differs from the filename, but not all, it uses the title instead of the filename. For example, take these two images: ...
0
votes
0answers
29 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
0answers
167 views

Dynamic attachment WooCommerce Follow-Up Emails

I am using the WooCommerce Follow-Up Emails plug-in for my clients website. With this plug-in, I send a e-mail directly after the order has been finished, containing a custom template with WooCommerce ...
0
votes
2answers
14 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 ...
3
votes
1answer
111 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
161 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
2answers
77 views

Get the path of the first attached media (single.php)

I'm currently developing a wallpaper website using WordPress and I'm trying to figure it out how to retrieve the path of the first attached media in the post so I can display the path in the post ...
0
votes
0answers
480 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
21 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
0answers
65 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"); ...
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 ...
2
votes
1answer
145 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 ...
0
votes
0answers
69 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
150 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
37 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
195 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
73 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( ...
1
vote
0answers
36 views

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

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
90 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
28 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.
2
votes
0answers
44 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
36 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
149 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 ...
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 ...
0
votes
1answer
97 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
0answers
116 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 ...