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
2answers
15 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
13 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
18 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
30 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
29 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
16 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 ...
0
votes
1answer
21 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
11 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
19 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
27 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
27 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
0answers
39 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
17 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
26 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
15 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
23 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
20 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
19 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....
0
votes
0answers
38 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
7 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
19 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
42 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
59 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
19 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
8 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
48 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
63 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
17 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
42 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
26 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
27 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 ...
1
vote
1answer
57 views

Adding Featured Image to Post programatically

How do I add a Featured Image programatically, given the URL/filename of the image, and Post ID associated with it?
0
votes
0answers
35 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. ...
0
votes
0answers
6 views

Determine From Database or Export File Whether Full Image or Not

I have a Wordpress export file. How do I tell whether an attachment is the original or not? I need to import the original and skip any versions of the original such as thumbnails, etc.
0
votes
1answer
32 views

How does WordPress treats attachments metadata in post content?

I understand that an "Attachment" object can have its own metadata in Media Library. However, it can also have it's own metadata in a post scope. How does WordPress deals with attachment metadata? ...
1
vote
1answer
51 views

Link to the parent post in attachment page

I want to show a link on the attachment page which takes one back to it's parent post. Currently in my theme I do not have that option, the links I get on the attachment page are Previous/Next links. ...
1
vote
0answers
27 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
76 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 ...
3
votes
1answer
32 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
1answer
80 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-...
0
votes
1answer
19 views

How to open an attachment based on the date picker

I am creating an E-Paper kind of functionality in WordPress where the user will have to select a date from the date picker and the corresponding attachment will open. I looked all around but didn't ...
0
votes
0answers
173 views

Send data url string as an attachment in wp_email

We have a data url string of png image file here and we can pass it via ajax to a php function via button click. Now is it possible to convert it back as image file and add as an attachment to ...
0
votes
1answer
37 views

ajax delete value from custom field array

I have on my page a multi file upload that saves post attachments within a custom field --- if (!empty($_FILES['vidPix']['tmp_name'][0])) { $i = 1; $files = $...
1
vote
1answer
203 views

Email Attachment from Form Submit

I am currently encountering a very strange problem. With the help of two existing wordpress functions (wp_handle_upload and wp_mail) and a form that uses some custom ajax functionality to process my ...
0
votes
1answer
66 views

Save attachment custom fields on front end

I have a front end post form that lets users upload multiple photos and on there I have 2 input fields to try and save custom meta data for each attachment - $vid_pix = get_post_meta($v_Id, 'vid_pix',...
0
votes
0answers
7 views

redirect attachment media pages to a new directory

I'd like to add all my attachment media pages to a new category I created called "none" /none/. Then Im going to block /none/ in my robots.txt because I hate attachment media pages. So I tried the ...
0
votes
0answers
14 views

Using 'post_parent' only works sometimes for attachments

I need to get all attachments with a specific post parent. To do this I used the following code: //this doesnt work $attachmentsids = get_posts(array("posts_per_page" => -1, "post_type" => "...
0
votes
0answers
16 views

Rename All Attached Image on Post

I have this code from a plugin that renames all featured image, how can i make this to rename all attached images on my post not only the Featured Image. Thanks!: public function wpRFP_rename_fimg($...