Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
0answers
10 views

Some Images are not showing on attachment page?

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", ...
1
vote
1answer
23 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 ...
0
votes
0answers
20 views

How to view exact image dimensions of a media in Admin view?

I know programmatically we can see the attachment sizes in templates, but I'm looking for a way to see the precise dimensions of the resized medium, large, xlarge sizes too. No plugin seems to do this,...
0
votes
0answers
10 views

Retrieving Gutenberg image block's caption

I have been trying to retrieve the image block's caption text to use in a PHP file. I understand Gutenberg (Block Editor) is relatively new so I haven't found any documentation on this topic. I have ...
0
votes
1answer
16 views

Get list of posts from attachment

My gallery has dozens of images. Next to each image, there should be links to the posts attached to that image. (You can see these in Media Library, under "Uploaded To"). I am able to retrieve the ...
0
votes
0answers
25 views

how to get custom attachment url?

Is there a common method to get a custom attachment URL regardless of the plugin or custom code used? Say if I use ACF plugin I can create an image field and get the url with get_field('fieldname'); ...
2
votes
0answers
15 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 ...
0
votes
0answers
11 views

select Multiple file from Media on mobile device

on a front end form I am using media uploader to attach multiple images to a posts. however on mobile device I can not select multiple images from the media. is there a workaround?
0
votes
0answers
13 views

How can I add links to posts and pages using a particular image from its own media attachment page?

I have various media attachment pages e.g. https://www.artobatours.com/rock-art-abric-del-mas-den-ramon-den-besso-muntanyes-de-prades-catalonia/ where I have the image and some exif data. Along with ...
0
votes
1answer
27 views

Delete attached images from posts

I exported posts from site X to Y. But in every post on site X there was image attached to it (not featured image) <a href="http://x" rel="attachment wp-att-25425"><img src="x/wp-content/...
0
votes
0answers
31 views

Filter not applied to all image sizes

I have a callback applied to wp_get_attachment_image_attributes to add attributes to the generated image html. function add_lazyload_to_attachment_image($attr, $attachment) { if (strpos($attr['...
0
votes
0answers
20 views

Using unzip_file() to get contents of file

With each post, I save a zip folder as an attachment containing a json file with large amount of data. When looping through posts, I need to open this folder and retrieve the contents of json file but ...
0
votes
0answers
35 views

Zip a file and add as attachment

I first add support for mime type attachments // ADD MIME TYPEs FOR ATTACHMENTS add_filter( 'upload_mimes', 'my_myme_types', 1, 1 ); function my_myme_types( $mime_types ) { $mime_types['txt'] = '...
0
votes
1answer
28 views

Nothing found in uploads folder after wp_insert_attachment

I'm trying to add a text file as an attachment I first enabled the mime type add_filter( 'upload_mimes', 'my_myme_types', 1, 1 ); function my_myme_types( $mime_types ) { $mime_types['txt'] = 'text/...
0
votes
0answers
47 views

I want to view PDF files in attachment page (attachment.php)

I want to view PDF files in attachment page (attachment.php) When uploading a PDF file it is not reviewed but appears as a link to download
0
votes
0answers
81 views

Attachment metadata randomly missing

I have this website with about 3000 posts and 4000 images in the media library. For a long time now, some image thumbnails will randomly disappear from the media library: When I click to open the ...
2
votes
2answers
311 views

Regenerate missing _wp_attachment_metadata

For some reason, some of the thumbnails of my media library are randomly becoming missing. I've found out _wp_attachment_metadata isn't present in the database for those images with missing ...
0
votes
2answers
19 views

Attachement Meta DATA

we try to connect our Managment Software to Wordpress / Woocommerce. Our customers can edit and manage product, stock and category directly from our sofware. Wordpress Database is simply so we easly ...
0
votes
0answers
21 views

Attachment metadata has value of '1'

While accessing /wp-json/wp/v2/media endpoint I'd got an error 500. Checking the logs, I'd seen the following issue: PHP Recoverable fatal error: Object of class stdClass could not be converted to ...
0
votes
1answer
24 views

hide attached images of a post

I've read an article on how to implement a custom Gallery template in wordpress posts or pages. I have a simple question, is it possible to not show the attached images inside the post content but ...
0
votes
0answers
6 views

Attachment Page is not scraped by Facebook object debugger and returns 404 on W3 validation checker [duplicate]

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 ...
0
votes
1answer
149 views

Gutenberg Block: Image resolution

Using the media upload element I created a custom Gutenberg block, that includes an image upload button. Now I would like to achieve one of the following: When an image is selected, it should select ...
0
votes
0answers
81 views

What is wrong with my wp_insert_attachment code?

I am attempting to upload company logo images to my Media Library - but I am noticing some problems... Namely, some of those images seem to come in at 0Kb created. Source image URLs are all like ...
0
votes
0answers
20 views

Sending Form data as Attachment

on my wordpress site i have a form where users can register to our club. Now the software we are using to handle all the club members allows to import a new member via a csv file. Now my thoughts ...
1
vote
1answer
81 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?
0
votes
2answers
33 views

Attach media to multiple posts

I have a simple code where I am attaching existing in the library image to a post: function attachToPost($attachmentId, $postId){ return wp_update_post(array( 'ID' => (int)$...
1
vote
1answer
23 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() { $...
0
votes
1answer
57 views

Adding attachment custom field metadata to TinyMCE <img> tag

I've successfully added a custom field to the media upload dialog, but now I need (1) this field to be present on the <img> tag on post content whenever an image is inserted, and (2) a way to ...
0
votes
1answer
106 views

Attach a external file as attachement using wp_mail

I am trying to attach external file link (doc file) as attachment but not able to so .. no attachment is being attached.. $email_attachment = array('https://ucarecdn.com/8aa17c61-bd55-4311-8b45-...
0
votes
1answer
82 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 ...
0
votes
0answers
20 views

Convert attachment page link

We need to convert my attachment page link from : https://example.com/?attachment_id=236813 to https://example.com/media/p_e-nX-omvhir-eAMvxwf0221 Where is p_e-nX-omvhir-eAMvxwf0221 is the images ...
0
votes
0answers
43 views

How to add Pagination on post_type attachment?

I have a WordPress page that displays all attachments attached to a post instead of the post itself and I want to add paginations to it. The problem is that the pagination only appears if I change ...
0
votes
0answers
20 views

Get images if post title contain mention keyword and image title contain other mention keyword

I want to show images on my custom page but with condition. I mean if my post contain "Keyword 1" and image contain "Keyword 2" I want to show that images. Now I have many posts that's title contain "...
1
vote
1answer
36 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 ...
0
votes
0answers
23 views

Using WP Attachments page as an slider

I'm working in case where you only retrieve 1 image of a custom structure gallery; then that only image will take you to attachments.php where I'm trying to get all the images of the that post in an ...
0
votes
0answers
23 views

wp_get_attachment_image_src calling wrong location

We are using the Exopite Simple Options Framework framework in our plugin. One of the fields is an image upload metabox: This works fine and images are uploaded and attached to the post as expected....
1
vote
0answers
129 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 ...
0
votes
0answers
17 views

How to get attachments urls if text match?

Is there any plugin or code that can help me in this. I want to fetch images that have to include text in their file name that I mention on my page or in code. I mean I want to display all images if ...
0
votes
1answer
8 views

Updating the attachment from front end doesn't show the new change

I am submitting an image to the db like this: if (isset($_POST['uploadImgCustom'])) { $myNewImg = get_post_meta($id, 'usp-file-single', true); } $attachments = get_posts(array( 'post_type' =&...
0
votes
1answer
23 views

Dupplication of Custom Post Type while adding attachment

I'm facing an annoying issue that I can't solve. I've made this code in order to add or update an attachment on a custom post type : function add_update_attachment( $postID, $photo ) { if ($...
0
votes
1answer
321 views

wp_mail not sending attachment

My mail function is as follows add_action('wp_ajax_order_processing', 'order_processing'); function order_processing(){ include 'mail-translations.php'; require_once( ABSPATH . 'wp-admin/includes/...
1
vote
2answers
140 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 ...
0
votes
1answer
46 views

Using delete_attachment to prevent an attachment not working

I'm having an issue where the attachment is being deleted despite me returning false function action_maybe_delete( $id ) { echo "Let's not delete Attachment id: " . $id ; // prevent the ...
0
votes
1answer
10 views

Remove post with attachments hook

So I have a link that removes a post. I also have some code in my functions.php wich should be hooked to the wp_delete() function. However. The function doesn't seem to work. What am I doing wrong? ...
0
votes
1answer
49 views

copy attachments to another post type and change attachment url

On my site I have to custom post types and a function that let's users import photos from post type A to post type B, copying the meta values and it copy's the image to the folder specified for post ...
0
votes
0answers
158 views

wp_delete_attachment doesn't delete image files / doesn't work

wp_delete_attachment should delete everything that is about attachment. However if I do wp_delete_attachment( (int)$delete_attachment_id, true ); The files remain on the server (even true should ...
1
vote
0answers
24 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 ...
0
votes
1answer
49 views

Get attachment URL from attachment Link in WordPress

I have been trying to fetch the URL of image attachments ( e.g. - http:// localhost/mytheme/post-format-gallery/100_5478.jpg ) using their attachment links ( e.g. - http:// localhost/mytheme/post-...
0
votes
1answer
45 views

Removing images deleted from uploads folder, from Media Library

How can I remove images that have been deleted from the upload folder, from the Media Library?
0
votes
1answer
38 views

Setting an image as post header (not featured image)

I am not a WordPress expert and need your support. Is there a way to create a button just like Set featured image but that button will allow us to attach an image to a post (from gallery) as a meta ...