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
0answers
12 views

Open the attachment details modal

The newer versions of WordPress, and possibly older ones, open an attachment details modal window when an image is selected in the media library. Is there a way that I can open this modal on a ...
0
votes
0answers
66 views

Delete attachment script

I have script, but only half works. It deletes "alternate" post but not delete the attachment. The script: function cs_delete_directory_post(admin_url, post_id){ if(confirm('Delete Post')){ ...
0
votes
0answers
10 views

Get post attached in sequence

I'm trying to do a reader, that will take images that are attached to the post.Kinda like a comic book reader, which has a button to the next image. However only saw snippets that show to catch the ...
0
votes
0answers
14 views

After I upload a file to library its name converted to dashes

I've a problem when I upload Attachment file (any extension) with Arabic name, for example اسم الصورة.jpg, It renamed to -------------.jpg ! I've plugins to crop the uploaded Image, I tried to ...
0
votes
2answers
17 views

Getting a taxonomy's thumbnail url

This is how I am currently trying: $taxonomies = array( 'product_cat' ); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => ...
0
votes
1answer
29 views

Get the title and URL of the attachment parent post

Goal: From my image.php, I am displaying the attachment image and some descriptions. I also want get the post from where it was originally posted. I only need the title and the url so that you can ...
0
votes
2answers
20 views

get_post orderby not working in plugin

Please take a look at the loops below, I'm having issues trying to order the attachment by title, name, and modified. <?php foreach ($instance['data'] as $id) : ...
2
votes
1answer
31 views

How can I display image metadata?

I'm trying to add a filter to the_content that will find all images in the post and append the custom attachment metadata credit to it. Here's the functions I've have: Adds the Credit field to ...
0
votes
0answers
10 views

Attach image from a folder while inserting post from CSV file (1 post)

I have a CVS file with almost 5000 records and I want to insert records into custom post with custom fields. I have one column (attachment) image type and I want to insert and attach image into the ...
0
votes
1answer
22 views

Change permalink to attachment

Hello i found this code and I modified a litle, but i have a problem with it. I want the link of the attachment page to be something like this [post-permalink]/[gallery]/[postid] 1234/ .. /1253/ ...
0
votes
2answers
27 views

Creating attachments archive in tags and categories

Per this question (How to create an attachments archive with working pagination?), I've been using the following function to have archive pages display attachments as well as pages and posts. It was ...
0
votes
0answers
9 views

Change the number of attachments loaded into the Media Popup window

I wish to ask if is there a way to change the numbers of thumbnails loaded in the media popup when it first opens. The Media Popup loads thumbnails through ajax (query-attachments), executing up to ...
4
votes
0answers
52 views

Get upload URL by blog ID in multisite

The essence of the question is, I'm looking for a solution like this: $blog_upload_dir_info = wp_upload_dir( $date, $blog_ID ); $blog_upload_url = $blog_upload_dir_info[ 'baseurl' ]; Where ...
0
votes
0answers
18 views

Include gallery in attachment permalink

I need a fix for my gallery attachments on WordPress. Now when adding a gallery the permalinks are something like that : mydomain/the_post_name/image_file_name/ But I want to do something like ...
0
votes
1answer
33 views

JSON API Plugin not showing Attachments id reused

First of all, I am talking about this plugin: https://wordpress.org/plugins/json-api/ So now regarding my problem: The plugin is working fine and without any problems. All attachments are showen for ...
1
vote
0answers
31 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
0answers
7 views

Paginate Multisite Attachment WP_Query

I am working on a multisite blog network where I need to display x post per page and navigation at the of the bottom list. My code will not display a pagination at the bottom and displays x post per ...
0
votes
0answers
16 views

How to hide media link to settings?

I want disable MEDIA LINK TO settings for authors. I tried following code, but authors are still able to change settings. add_action( 'print_media_templates', function(){ echo ...
0
votes
0answers
38 views

Removing default alt text autofill or overriding it

What I'm trying to do is check if the user has entered the alt text for an image, and if not, then add alt text containing the post title to the image. I found a function that does this here: ...
0
votes
1answer
34 views

Media library images “missing” after migrating them using SQL

I am migrating a lot of posts from an old site to a new site, and these posts have a lot of Advanced Custom Field "relationship" data attached to them. Because of this, I want to keep all of the ids ...
1
vote
1answer
45 views

Get Attachment ID from URL [duplicate]

I have the URL of an image which I know is an attachment. Now, I need to find out the attachment ID. This is what I've got (thanks to PippinsPlugins): // retrieves the attachment ID from the file ...
0
votes
0answers
17 views

Can I attach the data from one post to another?

I'm looking to create a "snippets" plugin of sorts that lets me create a library of snippets. I then want to be able to attach those snippets to a post but not within the post_content. I basically ...
0
votes
0answers
13 views

How to pick up featured image from set of pictures

I'm trying to create front end form for posting. The following questions are concerning me so bad. How can I set a featured image? I tried set_post_thumbnail($pid, $newuploadid); but nothing happend. ...
0
votes
1answer
48 views

Insert attachments from front end form

I built a front end form but suddenly cannot submit my image attachments. Refer to these articles which do not get it done: ...
0
votes
0answers
30 views

Strange problem with wp_get_attachment_image_src database (db) query count

I have a purchased theme that has a custom WordPress loop in it that looks for image attachments via wp_get_attachment_image_src. It does this by doing the following: $image = ...
0
votes
1answer
55 views

How can I bulk delete media and attachments using WP-CLI?

I'm trying to mass delete 4000 images in a wordpress website. WP itself sets the max to 999, which would work fine and take a few minutes to delete them via the backend. However, I get REQUEST URI TOO ...
0
votes
0answers
10 views

Why WordPress attachments LINK TO settings are not working?

Using this code below, I added some on-hover share icons for all images of the content. But, now these images are not getting any "Link To" setting from authors. I don't know what is the problem. Can ...
0
votes
2answers
49 views

How to get images only attached from edit post page

I have developed a custom wordpress panel with a custom front-end recently. In single post pages there is a slider. I display the result of get_attached_media( 'image' ) function as the images of ...
2
votes
1answer
56 views

wp_get_attachment_image_src and server path

wp_get_attachment_image_src will give me URL and dimensions for an image. But is there any way to get the server path for a scaled image (like ...
1
vote
1answer
46 views

How do I change attachment slug from name to id

I need to change the slug of the attachment post. Currently, it is showing attachment name , I want it to be replaced by id of attachment. Edit : Thanks to suggestion by TheDeadMedic, I am now ...
0
votes
0answers
18 views

Prevent user to see detail view of attachment of another user

This plugin prevents unprivileged users to see images, that other users uploaded: add_filter('parse_query', 'own_content_only_restriction' ); function own_content_only_restriction( $wp_query ) { ...
0
votes
0answers
37 views

How to change html generated by wordpress media uploader

I have managed to change the output of wordpress media uploader using image_send_to_editor exampled below (where the output is image:($url)) However I want to do the same with other files like ...
0
votes
1answer
43 views

Hide Image Container if No Image Attachments

I have a CPT that displays any attached images via a slider. However, when there are no attached images the slider still appears. Is there a way to add a conditional IF statement that will hide the ...
0
votes
1answer
26 views

Getting attachments by meta value

I'm stuck at a very simple point: I need to get all attachments by a custom meta key (and value). I'm developing a short code, so it has to work on every possible page. What I've tried so far: $args ...
0
votes
0answers
22 views

Duplicate Button on Attachment Details Modal

I tried to find a solution, but no success. I need to add duplicate button on the bottom of Attachment Details Modal Window ( where are "View attachment page | Edit more details | Delete Permanently" ...
0
votes
1answer
53 views

Adding meta data to an attachment post

I want to add a meta data to my attachment posts, so I can get them in order by meta value later. That meta value would be 'price'. So I thought this could work: I have this args: $args = array( ...
0
votes
1answer
76 views

Wordpress wp_get_attachment_thumb_url full

My code in index: (show all attachment by one post ID) <?php query_posts('p=1498'); if (have_posts()) { while (have_posts()) { the_post(); ?> <?php $args = array( 'post_type' => ...
1
vote
0answers
23 views

How to import files to individual posts of a custom type

I'm very inexperienced in WP, so I may have some fundamental misunderstandings - definitely open to alternative approaches if this one is crazy! I have a collection of several hundred files, split ...
0
votes
0answers
26 views

post attachment's direct link only available to logged-in user (custom role)

I am making very simple PDF / DOC document library. I am handling the document upload using "ACF File" field (uses the native and core WP attachment functionality). There will be a page that displays ...
1
vote
1answer
85 views

How to check an ajax nonce in PHP

I'm modifying the media modal adding a new menu item to add external attachments to the media library. From the JS code I'm calling a PHP function that touches the database and accepts three ...
1
vote
1answer
62 views

Get attachment by meta_key value

I need to get the attachment (will be only one per post) associated to a post with meta_key wpcf-legislacion-gratis (not matter the value the column has) by using a custom query using get_posts() ...
0
votes
1answer
39 views

How can I display custom fields value from attachment media?

I have created the follow code in functions.php to add custom fields to attachments media library. Data saves as well, but I can't get data to display into the template file. Any suggestion?? Thanks! ...
0
votes
1answer
78 views

How to create a CSV on the fly and send as an attachment using wp_mail?

I'm trying to create a CSV file from a form submission and send that file automatically by email to a specific user. The email itself is sending fine, but I can't get the attachment to go through. Is ...
0
votes
0answers
26 views

Automatic category assignment upon attachment upload

Lets say the media library has the following category [news, events, photo, page, post] Your wordpress also has the above 5 set as post-type. What I want is when 1- Events -> Add New 2- File is ...
1
vote
0answers
69 views

How to trigger a refresh in the media modal

I'm developing a plugin that adds a new tab to the media modal, and I need to know a way trigger a refresh of the attachments tab so it shows newly added attachments. This is the code I'm using: ...
4
votes
3answers
150 views

Stop WordPress from reserving slugs for media items?

I am experiencing some odd behavior, that apparently happens "out of the box" with WordPress. If I upload a file through the media manager called: services.jpg; then go try to create a page with the ...
0
votes
0answers
41 views

How to get blog id of a post from admin panel?

I have multi-site and using add_attachment($post_id) hook to get the $post_id whenever a binary file is uploaded. I need to figure out the $blog_id of that post. How would I go about doing this? I ...
0
votes
0answers
31 views

Automatically attach image to post if they have the same title

I have 200 images in my WP install. Currently, each image... has its own post (the post title is the same as the image title) is the featured image of that post is inserted into the post ...
0
votes
1answer
36 views

How do you import images from a URL in your post?

I am looking to automatically set the featured image from a URL, I have a plugin that creates new posts and has a link back to the source website, I would like to be able to scrape that link for an ...
0
votes
0answers
25 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 ...