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.

266 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
208 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, ...
5
votes
1answer
232 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?
5
votes
1answer
160 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 ...
4
votes
1answer
275 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 ...
3
votes
0answers
1k 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 ...
3
votes
1answer
44 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 ...
3
votes
1answer
1k 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 ...
3
votes
0answers
224 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 ...
3
votes
1answer
153 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 ...
3
votes
1answer
124 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) ...
2
votes
0answers
68 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 ...
2
votes
1answer
200 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?
2
votes
1answer
89 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-...
2
votes
0answers
298 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', '...
2
votes
1answer
175 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 ...
2
votes
0answers
103 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 ...
2
votes
0answers
546 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 ...
2
votes
0answers
446 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, ...
2
votes
0answers
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 ...
2
votes
1answer
345 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 ...
2
votes
0answers
104 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 ...
2
votes
1answer
169 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. ...
2
votes
2answers
307 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 ...
1
vote
0answers
28 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 ); ...
1
vote
0answers
12 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 ...
1
vote
0answers
32 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' ...
1
vote
1answer
110 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 ...
1
vote
0answers
17 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 ...
1
vote
0answers
10 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 ...
1
vote
0answers
262 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 ...
1
vote
1answer
84 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 ...
1
vote
1answer
44 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() { $...
1
vote
1answer
254 views

Media library quick/inline edit

Posts and pages offers the opportunity for inline editing (Quick Edit), i.e like this. It is also possible for custom post types, but for some reason this is not offered for attachments/the media ...
1
vote
0answers
276 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 ...
1
vote
2answers
544 views

How to do string attachment with wp_mail

I'm using a gift card plugin for my woocommerce shop and I would like to add a generated pdf file to allow customers to download the gift card as a pdf. The idea is to use TCpdf or Fpdf to generate ...
1
vote
0answers
39 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 ...
1
vote
0answers
60 views

I have a site where attachments in the wp_posts table have guid values of guid, how did this happen?

I realise comparing this particular website with all the other WP sites I've built that all the others have the image url in the guid column of the wp_posts table, yet this problem site just has "guid"...
1
vote
0answers
296 views

How can I attach Facebook Open Graph data to an Attachment Page?

I have code in my page header which properly creates the Open Graph tags for pages, posts, etc. However, when I attempt to Share an attachment post from the Media Library (not the actual attachment ...
1
vote
0answers
751 views

Send multiple attachments with wp_mail in PHP

I'm trying to send multiple attachments with wp_mail() , after some issues of attachments names (it displayed something like phprTxfd.pdf instead of file_name.pdf), i succeeded to display the name of ...
1
vote
1answer
26 views

Get all attachment by post excluding featured and content inside

I have a portfolio where for each item i have some images inside the content, a featured image and a custom filed called "portfolio images". I want to get all images by post excluding the fetured ...
1
vote
0answers
379 views

Fetch wordpress video attachment with post ID

So I have wasted 5 hours of my life to figure how to fetch wordpress custom post videos and been unsuccessful and here i am. Looking for expert advice. My Requirement: - Fetch all video attachments ...
1
vote
0answers
129 views

“Scattered” gallery

I'm building a theme for a portfolio-type site. I'm looking for something like this: This site uses some kind of Foundation Grid CSS to size the thumbnails using different sizes. My question is, ...
1
vote
0answers
32 views

Prevent Delete Attachment by URL or When Submit

This code is working, which prevent being deleted by specific title: add_action( 'delete_attachment', 'check_relations' ); function check_relations( $post_id ){ if(get_the_title( $post_id ...
1
vote
1answer
58 views

Get attachments from a post

I created a snippet to get all attachment from a post, included attachments from comments. <?php $post_attachments = get_posts( array ( 'post_type' => 'attachment', 'posts_per_page' =&...
1
vote
1answer
40 views

Stopping WordPress from Auto Generating Image Files for Sizes

I have a custom post type with an image upload meta field. Every time I upload it an image with it though, I am getting extra image files for each of the predefined sizes from the theme's functions....
1
vote
1answer
455 views

How can I store a file in the database in the same way WordPress and ACF do?

I'm taking input from a Caldera Forms form which includes a user upload. This is returned as an array containing the file name: ["company_logo"]=> array(1) { [0]=> string(73) "https://...
1
vote
0answers
333 views

Open the Attachment Details popup

I'm trying to open the Attachment Details popup, but with this code it shows all the images jQuery(document).ready(function($){ $( '.attachments' ).on( 'click', '.attachment', function( event ) { ...
1
vote
1answer
72 views

Check what attached image size is used

I have registered new image size wide-image which should be wrapped inside custom div. I haven't found any wordpress function which gives me the power to check what size of the attached image is used. ...
1
vote
0answers
482 views

hook wp_generate_attachment_metadata does not read all the attachments

I am using GD libraries in order to modify the uploaded attachment so I can have always the crop at the same squared dimensions with white stripes top/bottom or left/right if the image is not squared ...
1
vote
0answers
29 views

How to filter a post in the Tag Cloud widget, using tags of a media library image attached to the post?

I hope my question is rather common. There are some posts. These posts have images as attachments. These images are stored in the Media Library and have tags based on custom taxonomy. Obviously, if ...

1
2 3 4 5 6