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

attachment page 404

after I uploaded some files into media library, I click "View attachment page" in "attachment details", but I got a 404 not found. the URL is like "http://123.456.789.123/filename/". there is ...
0
votes
1answer
11 views

Delete all attachments not used in post?

The site has 14,083 files, at least 3,000 are not used in publications. How do I delete all the images that are not attached to the post?
0
votes
1answer
16 views

WP media attachment location vs permalink

Yesterday I moved my sites from http://www.example.com to (secure site and removed the www). Now when I look at an attachment page I see the File URL as the old http://www ... but the page permalink ...
0
votes
0answers
8 views

wp_upload_bits Upload Specific Sizes Only

For images uploaded using this code, I want to only upload the full-size image and the thumbnail (whereas for images uploaded through site, I want all sizes). However, I can't figure out how to make ...
0
votes
0answers
8 views

Media settings image sizes ignored in attachment display settings when uploading image

I know this question has been asked before here; Settings in 'Media > Settings' is ignored when inserting images I tried all suggestions and none of them work for me. I've set the image ...
0
votes
0answers
9 views

Prevent non-admin to deattache media

We use Woothemes Sensei plugin as our Learning Management System. We also use Sensei Media Attachments plugin, in order to attach PDFs to our lessons CPT. Well, from time to time some PDFs are being ...
0
votes
1answer
9 views

Get posts associated with media attachment

Is there a good way to find all posts that contain a specific image? I'm working on the attachment single template, and I'd like to list the posts that contain that image.
3
votes
0answers
34 views

Uploaded images don't show in Media Library if there are special characters in IPTC Keywords

Some images that are uploaded to Wordpress don't show up in the Media Library. The images get uploaded and even cropped to the defined sizes, there is an entry in the Media Library, but the preview ...
0
votes
0answers
11 views

Redirect Attachment to parent or homepage not working on Firefox

to prevent attachment pages to be indexed in SERP, I usually use the option in Yoast SEO plugin to redirect attachment to post parent page. But it does not work when an attachment has no parent, that ...
0
votes
1answer
20 views

How to Insert images in WordPress using code

I am trying to create a plugin for auto posting. I was able to create new post and then get the attachment for the post. But images are not showing inside the post itself. but if I click on media ...
5
votes
1answer
45 views

Detect if is image unattached

I have problem with unattached attachments. I use image.php to show Wordpress image gallery. I always show "big image" (for current clicked image)...and under that image I show rest thumbs from that ...
1
vote
2answers
46 views

How to access featured image?

I saw this code as how to set a featured image for a post: // required libraries for media_sideload_image require_once(ABSPATH . 'wp-admin/includes/file.php'); require_once(ABSPATH . ...
6
votes
2answers
149 views

Remove Dimension from wp_get_attachment_image

I am having some issue removing the width and height from my attachment images when using wp_get_attachment_image. This is what I am using to display the image <?php echo $image = ...
0
votes
1answer
37 views

Why does wp_mail become so slow when adding a local file attachment?

I have a mail template in Contact Form 7 3.5.4 where I add a standard file attachment which is already on the server (PDF of about 10MB) to an email. I receive the email including the attachment and ...
0
votes
0answers
31 views

Set Attachment Image File URL as GUID

I have a form that uploads images and i want to update the GUID to be the attachment file url after WP generates the metadata. I tried to use wp_update_post, but seems that is not updating the guid. ...
0
votes
1answer
52 views

Upload and attach to a post multiple image files [closed]

In a front end form I have a 'multiple' input field for uploading and attaching images to a post and a processing script (from here). I expect that will be uploaded and attached all files that I have ...
0
votes
1answer
29 views

How to get image URL from media_sideload_image?

I upload external images for media library using following way. $new_image_url = media_sideload_image($new_url, $post_ID, $title); This method return complete img src tag or 'src' for the image ...
0
votes
1answer
70 views

Delete post image attachments with jQuery from the front end

In my WP 4.4 Twenty Sixteen child theme I want to delete post image attachments from a front end form created by a plugin. To achieve this I followed this answer, but the delete links doesn't delete ...
0
votes
1answer
18 views

Delete custom post type metadata without deleting the post in admin area

I'm working on a plugin for a client and they need the ability to attach a couple of PDFs to a post as metadata. The client will need to occasionally update these attachments but without deleting the ...
0
votes
1answer
41 views

Redirect attachment URL

Is anyone able to Redirect the following permalink URL for me? The URL that WordPress is: http://example.com/?attachment_id=411 I would like to redirect it to new structure i do it, The following ...
0
votes
3answers
30 views

What will happen if I delete all my attachment type posts from database?

OK maybe I'm a bit hysterical about performance, but I don't see any reason to have more than double the post entries I need in my database. I mean every image automatically creates an attachment ...
0
votes
0answers
24 views

How to update post_parent on images uploaded via Add Media button from front-end

I'm working on a plugin that will allow registered users to post content from front-end. I added WordPress default Add Media button on TinyMCE and noticed all the images uploaded via Add Media get ...
0
votes
0answers
13 views

How to replace attached media through programmatically?

I am not sure, whether the similar question exist before. I tried to get but , couldn't get the similar question. Actually I want to replace an attached media with new image. Which Means, I am ...
2
votes
1answer
40 views

Attachment page per category

I want to display a custom attachment page for a specific category, i.e. attachment page for category wallpapers should have a different template than category cars. Any suggestions?
1
vote
1answer
33 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
15 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
20 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
311 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
27 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
51 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
30 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
26 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
10 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
22 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
43 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
10 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
37 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
34 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
11 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
41 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
13 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
31 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
129 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
19 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
33 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
18 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
34 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
18 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
110 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 ...