Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [attachments]

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.

278 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
13 votes
0 answers
350 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, ...
Sacer's user avatar
  • 131
5 votes
1 answer
456 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?
KKND_BLACK's user avatar
5 votes
1 answer
318 views

How can I append custom data to images in the editor?

I've added a custom meta field to my image details so that a client can add a number to their photos (a design choice). The data would need to show up under each image (like a caption) inserted into ...
robalan's user avatar
  • 747
4 votes
2 answers
869 views

Give attachments an archive page

I'm trying to override WP's default URL structure for attachments where, if they're attached to a post, the URL is /post-slug/attachment-slug/ and if not it's simply /attachment-slug/. What I'd like ...
powerbuoy's user avatar
  • 832
3 votes
0 answers
1k views

Make alt text required when setting a featured image

In the EU it will shortly be a requirement for public sector websites to have alt text for uploaded images. My organisation's users are rubbish at adding alt text, however, and I'm trying to find a ...
JohnG's user avatar
  • 334
3 votes
0 answers
2k views

Attachment page 404 not found when image is attached to post

I have this new WP webiste I’m working on. Today I was going to design the attachment.php page so that my image pages would look nice, but found that I was getting a 404 for all of them actually. I’ve ...
Guillermo Carone's user avatar
3 votes
1 answer
53 views

How can I add a fifth option to the alignment picker?

I'd like to have the following options in the image alignment picker: Left Right Center Full None Obviously four of those are there by default, but the "full" one doesn't currently exist. The idea ...
JacobTheDev's user avatar
  • 1,231
3 votes
1 answer
2k 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 ...
Riffaz Starr's user avatar
3 votes
0 answers
230 views

Pulling Post Image Attachments in WordPress 3.9

For some reason the functions I'm using for pulling post images/attachments isn't working after updating to 3.9, has something changed in the way we pull attachments? The code I'm using in single.php ...
contempoinc's user avatar
3 votes
1 answer
175 views

WordPress comment count to include attachment comments

How can I make the comment count on a post on my index page include comments that have been made on, in my case, individual gallery pictures that are included in the post? It seems that comments made ...
Jos's user avatar
  • 41
3 votes
1 answer
540 views

Display Single Attachment Image file size, uploaded date, resolution, file-name etc in Sidebar

Sorry for any wrong details. I am totally new to WordPress development. I am running a photo site. On single attachment page, I want to show the details (i.e upload date, filename, size, resolution) ...
Talha Basharat Ali's user avatar
2 votes
0 answers
168 views

wp_get_attachment_image_src() returns wrong url

wp_get_attachment_image_src() is returning a wrong image url. It returns the original url instead of the cropped one. Here some example code: $ptId = get_post_thumbnail_id( $productId ); ...
Ferdy Fiers's user avatar
2 votes
0 answers
73 views

How to get images from EDD post?

I use Easy Digital Downloads plugin and I wish to get images from the downloads posts types! But with my code, nothing return! Someone for help? <?php $attachments = get_posts( array( 'post_type' ...
Kevin Nry's user avatar
2 votes
1 answer
1k views

How can I get full attachment url from wp_get_attachment_metadata?

I want to get all sizes of an attachment. I can use wp_get_attachment_metadata to do this. But it only return filenames, not file urls. How can I do this? This is a workaround, but doesn't take ...
FooBar's user avatar
  • 444
2 votes
1 answer
697 views

How to change ID of an attachment in wp_posts and its related tables correctly?

I have two posts in my wp_posts table where post_type='attachment' The picture below shows the records related to those in wp_postmeta table I need to change the IDs of those files. What I am doing ...
Eray Balkanli's user avatar
2 votes
1 answer
495 views

ACF attachment custom field in rest response

I created an extra select option ACF field for media uploader and I would like to retrieve the associated values in Gutenberg MediaUploader onSelect. Is there a workaround for this case?
fefe's user avatar
  • 874
2 votes
1 answer
167 views

Display one random image, but only if landscape

I want to pull one random image and use it as a background image —- but ONLY if it's a landscape image. I found this post: https://stackoverflow.com/questions/37537577/wordpress-query-by-attachment-...
Tomasch's user avatar
  • 31
2 votes
0 answers
443 views

Issue to get wp_get_attachment_image with cmb2

I have a problem get the image with cmb2, I have tried in many ways without successm according to the documentation, this is fine, what can I be doing wrong? add_action( 'cmb2_admin_init', '...
Max's user avatar
  • 53
2 votes
1 answer
300 views

Edit default image attachment size

I am building a theme and I use single.php also for attachments. The problem is that Wordpress print automatically the images with the_content() in this way: <p class="attachment"> <a ...
Claudio King's user avatar
2 votes
0 answers
192 views

Perform a custom (bulk) action in media view

I wish to figure out how to add a custom action button in the media grid view ( upload.php screen) and how to perform a custom (bulk) action to the selected attachments, as shown in the screenshot ...
Virgo's user avatar
  • 99
2 votes
1 answer
350 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 ...
Pamela's user avatar
  • 161
2 votes
0 answers
689 views

How to make a customized "Create Gallery" tab in the 'Add Media' window?

I'm developing a plug-in and wanting to make a customized version of the the "Create Gallery" tab of WP v4.0, but have the resulting output (i.e. what gets inserted into the TinyMCE editor) to be ...
mwKory's user avatar
  • 21
2 votes
0 answers
486 views

Reorder "menu order" of attachments to another predefined order

I want to show photos attached to a post in a gallery using the built-in system with a custom order. Currently with the [gallery] shortcode it is posible to order it by name, by upload date, by ID, ...
peroyomas's user avatar
  • 329
2 votes
0 answers
1k views

Prevent Duplicate Attachment When Using wp_insert_post

I am trying to use wp_insert_attachment while using wp_insert_post. It's successfully creating the post and attachment. It have no problem if I only use the wp_insert_post function, but when I ...
Ari's user avatar
  • 1,177
2 votes
1 answer
353 views

Rename attachments during upload no matter what filetype

Here's the function I use for WP to rename images during upload on the fly and set the image's filename to match the post slug. function wpsx_5505_modify_uploaded_file_names($arr) { // Get the ...
pereyra's user avatar
  • 475
2 votes
0 answers
109 views

Page Attachment Permalink Structure based on Menu Order?

I've been on a quest for the past couple of days reading up on Rewrite in WordPress but still can't seem to figure out how to accomplish this. When using pretty links in WordPress, media attached to ...
Travis Tubbs's user avatar
2 votes
1 answer
204 views

Converting Attachment to Images?

I've had no problem using lightboxes before with attachment images, but I've switched to a new theme called Quicknote and it seems that attachment images now instead link to the attachment page. ...
aroooo's user avatar
  • 121
2 votes
2 answers
323 views

Find first image on paginated post for Pinterest

I've been looking for days, yet can't find a good answer. Perhaps the SE crowd can be of assistance. Any help is much appreciated. I am using a custom-coded pinterest button included on posts that ...
Vlad Dusil's user avatar
2 votes
0 answers
581 views

Query_posts and attachments

I need some guidance on some WP code. I'm wondering if it's possible to take this code (which is grabbing all the images from the posts across my site and dumping them out): $args = array( 'post_type'...
John the Painter's user avatar
2 votes
3 answers
8k 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 ...
H Hall's user avatar
  • 21
1 vote
0 answers
22 views

How to insert information about the size and type of an attachment into page

I have a page and attachment addes to this page. Now I can output the content of this page with modified link attachment, when each attachment link otput title size and type of attachment like this &...
mardon's user avatar
  • 121
1 vote
1 answer
70 views

How can I get all attachments by a user on a WP multisite network?

I'm creating a front-end based project where users can make posts and add images to them. It's a network of sites that users have access to. For a better user experience, I want users to be able to ...
ToongeePrime's user avatar
1 vote
0 answers
39 views

on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query

Current behavior I have a media page that uses a custom WP_Query to return all thumbnails of media library attachments (regardless of post parent) with a custom taxonomy of media_visibility that has ...
Mike Eng's user avatar
  • 258
1 vote
0 answers
44 views

Why not attaching images after impoting using wp cli

I want to move posts from one site to another, because of the big amount of posts I am trying with wp-cli import. The destination site also has huge amounts of posts, now when I am importing XML files....
Mi2's user avatar
  • 11
1 vote
0 answers
63 views

Give attachments an archive page, and exclude unattached ones

I am extending the use of Media/"Attachments" so that they have a custom taxonomy of "Medium" and I can display taxonomy archives on the frontend. I'd only like the archive query ...
kanga's user avatar
  • 111
1 vote
0 answers
2k views

Insert woocommerce products programmatically with featured image and gallery

I'm inserting WooCommerce products programmatically to the database, but I'm having trouble inserting and linking first image as featured image and multiple images for gallery assigned respectively to ...
Archer's user avatar
  • 11
1 vote
0 answers
214 views

Add the description field on the attached media

Well, we want to add the description field on the attached media under the post edit page. I have attached an image for reference. Explanation: Under posts, after adding an attachment if we click on ...
Rajneesh Tiwari's user avatar
1 vote
1 answer
36 views

How can I get the number of custom post type posts that have a specific attachment image set?

I'm currently using this to filter out only posts that have a specific custom image attachment field value. But it's returning 0. I used this method for other custom fields and it worked great. Is ...
Charles Davel's user avatar
1 vote
0 answers
22 views

Customizing the attachement page to show rest of all images in a gallery from post

How to customize the attachment image page with previous and next navigation button and show below rest images in a gallery ? I just added a visual representation Post page Attachment page
Sreerajdesign's user avatar
1 vote
0 answers
12 views

Display images that are not in the content

The function below returns all the images attached to the post, however, if I delete the image inserted into the content, it still returns in the function, because the media is still as attached to ...
Renan Bessa's user avatar
1 vote
0 answers
409 views

how to upload a image from frontend with wp_insert_post and also update_post_meta?

I am using cmb2 for frontend form submission with custom post type name 'form'. But can not upload image with that. the first step is: array( 'name' => 'Image', 'type' =&...
Tajul Islam Saikat's user avatar
1 vote
0 answers
27 views

Set size for attachments

I am working on a custom theme and have generated content with FakerPress to include some uploaded post images. I want to ensure any image uploaded as an attachment in a post displays in one of the ...
user2004758's user avatar
1 vote
0 answers
38 views

how to get link of added document with a post

I am working on a mobile application with back-end wordpress database. In wordpress there is a button on each post container top with name of "Add Media" where we can add video , audio and documents ...
johni's user avatar
  • 11
1 vote
0 answers
16 views

How to show optimized list of posts with all their attachment images

In page-images.php template I have created this code which displays a list of posts which belong to a category and order them by meta value. So basically it is like a category page, generally nothing ...
Ivan Topić's user avatar
1 vote
1 answer
318 views

wp_set_object_terms not updating database without a die()

I have added custom taxonomy to media attachments. From the individual post page these are updating correctly, with some tweaks to get the column count updating correctly - and I can see these changes ...
Aravona's user avatar
  • 585
1 vote
1 answer
114 views

Where to put meta Keys

Hello im creating my custom checkbox in gallery and i already add that , but save doesn't work , can someone take a look and tell me where should i put meta keys ? function wporg_add_custom_box() { $...
Mariusz's user avatar
  • 23
1 vote
0 answers
580 views

Issue with wp_get_attachment_url() function for multisite

I have a WordPress site and I created the multisite network by following the below URL https://codex.wordpress.org/Create_A_Network And I am trying to upload files from frontend uploader form. The ...
Suman's user avatar
  • 161
1 vote
0 answers
421 views

Remove product category placeholder image (Woocomerce)

I'm trying to get rid of placeholder product category images on the shop page. Right now I'm using this code to add a .no-image class to products that don't have an image so I can style them ...
Richard Mišenčík's user avatar
1 vote
0 answers
136 views

Is it possible to share media files between multiple WordPress sites?

We've got around ten or so WP sites on different instances of WP (each with it's own database), most of them are on the same server but not all of them. We would like to achieve a situation where an ...
Richard B's user avatar
  • 398
1 vote
0 answers
1k views

How can I use an image from an external source without uploading it to the media library

I am looking for a way to tweak my xml parser code to insert a url from an external source into a new post, instead of first uploading it to the website's media library and than adding the attachment. ...
Vasco's user avatar
  • 111

1
2 3 4 5 6