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.

Filter by
Sorted by
Tagged with
0
votes
1answer
30 views

Do custom post type (CPT) attachments/media store the parent post ID?

Do custom post type attachments store the parent post ID, and if so, how do I retrieve it. I need to prepend the ID of a CPT post to the uploaded media name, eg 123-my-file-name.pdf I do have this ...
0
votes
0answers
13 views

How to change an image source when rendering on frontend?

when showing articles, let's say there are images with watermark. But of course, those images are somewhere else, the watermark itself is not rendered onto the source image. So, just before rendering, ...
0
votes
1answer
35 views

submit two file input fields in the same form

I have a form which has two file input fields, each input should be submitted in different metabox in custom post type, when I try to submit the form it takes only the first one and ignore the second ...
0
votes
0answers
14 views

Keep all media unattached

I am using a template to display my attachments, with their metadata, and the site I'm building requires a lot of standalone media. Whenever someone sets a page thumbnail, or connects a post object to ...
0
votes
0answers
13 views

How to modify an image Gallery block in WordPress?

simply i want to remove <figcaption> from every image and remove text between <figcaption> tag' <figcaption class="blocks-gallery-item__caption">Image caption</...
0
votes
0answers
17 views

Processing resized images upon upload

WordPress creates resized copies of images that are uploaded to the media library. When I upload an image, I want to do some processing on these resized images. Currently, I'm using a add_attachment ...
0
votes
1answer
33 views

How to get all attachment image from post ?? WordPress

I just want to get all atachment image from post with Alt, description, title, size, resotution and how to add DOWNLOAD button? i want to create image downloading website on wordpress for example LINK ...
0
votes
2answers
18 views

Get all image in media Gallery with alt/title?

Is there a way to fetch the ALT/TITLE of ALL images in the media gallery? I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media ...
0
votes
1answer
26 views

Use rich text editor in 'Edit Media', for attachment media description

I have the following in my functions.php: add_filter( 'wp_editor_settings', function( $settings ){ if( get_post_type() == 'attachment'){ $settings = [ 'wpautop' => true, '...
0
votes
0answers
39 views

Unable to delete related media attachments with deleted post

I want to delete the post attachments too from the 'Media" panel once a custom post is deleted. The post itself gets deleted well, but its media still remains in the wordpress "media" ...
0
votes
1answer
20 views

Auto delete content in specific folder inside media library

I am looking for solution to auto delete images (jpg, gif, png -content in general) inside a specific folder (folderx) INSIDE the uploads/months folders (customization intended for future folderx --...
0
votes
0answers
14 views

Enable Gutenberg for attachment edit page

I'm trying to get Gutenberg working when you edit media details (attachment post type). This is what I have so far: add_filter( 'register_post_type_args', function( $args, $post_type ){ if ( '...
0
votes
0answers
19 views

How to display a link to the post where an image is attached on the attachment template or attachment single page?

When viewing a single image or attachment, how can I display a link to a post where that image or attachment is attached? This is similar to the link in the edit media in the dashboard tjat is called &...
0
votes
1answer
29 views

how to get random media id from media gallery

I tried to get random media id from wordpress media gallery using this: $image_ids = get_posts( array( 'post_type' => 'attachment', 'post_mime_type' => '...
1
vote
0answers
46 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 ...
0
votes
0answers
42 views

How can i set media attachments to the author of the post or page for already existed posts with attachments

I have been uploading posts for multiple authors in my site and the attachements (photos) are registered all in my account. Is there a way to set the attachements to have the author of the post ? I ...
-1
votes
0answers
15 views

Wordpress Multisite Attachment Show In Media URL How Can I Remove

I moved my website to WordPress Multisite. But when I made a post and used the images in that post and linked the images with the attachment. Then Showing Attachment In Url https://oyepng.com/cat-...
0
votes
2answers
35 views

How do I update attachment urls after changing site domain

I recently moved my site from https://subdomain.example.com to https://example.com. Now all my attachments still point to https://subdomain.example.com/wp-content/uploads/2021/04/file.mp3 even though ...
0
votes
0answers
13 views

How can I add the Post Status option to the Admin for Media Library posts? I want to be able to set their Status to Private,

Is there a way to add the Post Status option to the Admin for Media Library posts (as with Posts and Pages)? I want to be able to set the Status of individual Media Library items to Private. My ...
0
votes
0answers
55 views

Attachment Page Permalink/URL Problem

I'm facing an issue with the attachment URLS. I want to redirect all my media URLS to my product pages but for some reason there are two kinds of URLS being generated for images. for example: example....
1
vote
0answers
25 views

How to change File URL in file uploaded to s3 compatible storage with self written plugin [closed]

I'm trying to write a plugin that uploads files directly to an S3 storage and allows to downloads them like files directly on the server. The main page of the plugin contains the following code for ...
0
votes
1answer
47 views

How to add a default predefined thumbnail when creating a brand new post?

I'm making a plugin that has a custom post type and I need to add predefined content. I used filters default_title and default_content for the title and content but I can't find how I can add an ...
0
votes
0answers
15 views

Adding images (attachments) without moving images to WordPress uploads structure

In 'Settings' >> 'Media', the checkbox is set for keeping images in folders by month and year. However, I'm trying to add a new folder (my-custom-folder), with a ton of new images, in a big ...
0
votes
1answer
21 views

How to add a custom field for image in "Text and Full Image(text right)" layout?

I need add another image in the standard "Text and Full Image(text right) layout" in WordPress. This layout by default has a field for an image. I located the php file that renders this ...
0
votes
1answer
28 views

WP_Query for Attachments not working as expected

I have a function to retrieve a random set of pictures according to the category. This has been working when I set up the website last year. Now I tested the site today and found out that none of my ...
0
votes
2answers
20 views

Get all post embedded images

i want to get a post embedded images but the only methods i see over the internet are $attachments = get_posts(array( 'post_parent' => get_the_ID(), 'post_type'...
1
vote
2answers
53 views

Audio file's length (duration) is missing from Attachment Details in Media Library [closed]

I'm uploading a different mp3 file to each post as an attachment and using wp_get_attachment_metadata() to print the duration of the mp3 file. Sometimes the response from wp_get_attachment_metadata() ...
1
vote
1answer
10 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 ...
0
votes
1answer
18 views

How do I assign an attachment to a post using only the REST API?

I am able to create a new post by sending a request with cURL against the REST API. That works fine. I am also able to upload files into the media library with cURL via the REST API. The uploaded ...
0
votes
1answer
84 views

Shortcode for Custom Field of Media Attachment (to use with Featured Images)

I'm using ACF (Advance Custom Fields) for Media Uploads to store location information about photos. When I set a post Featured Image to a photo that has this extra field, I'd like to output the ...
0
votes
0answers
15 views

Create fake media / attachments with no actual file

I am working on a project where I have to upload headshots of personnel, and then add a title and description to the media. For those who don't have headshots, I don't want to have to upload a dummy ...
0
votes
1answer
22 views

How do I add a medium to the Wordpress database with my own plugin?

I wrote a plugin that accepts files via Wordpress and saves them outside of the server. Now I would like to save the metadata as normal in Wordpress, as if the file were on the server. Is there a hook ...
0
votes
1answer
98 views

WordPress Attachment Page URL Rewrite!

I am creating a gallery site using FooGallery and having the individual images open in the attachment page. I tried a bunch of codes from here to rewrite the attachment urls from ?attachment_id=8184 ...
0
votes
0answers
14 views

How to attach images to the post ACF gallery form is submitted from

I have ACF and ACF Gallery Field plugin. I made a custom post type called "albums". In ACF, I made a gallery field called "album_images". Then in Elementor Pro, I made a template ...
0
votes
0answers
10 views

add_attachment hook Gutenberg

[UPDATE] Well, I was firing add_attachment into a conditional statement is_admin(), I suppose this is wrong. I am using the following code to fire when a new media is uploaded into the Media library. ...
0
votes
0answers
18 views

Does using the WordPress Import tool still include attachment data if "Download and import file attachments" is not selected?

I'm in a unique situation where I have to import WordPress content into a production server, but I don't have SSH access to the server files or database. I can't install plugins on the production ...
1
vote
0answers
31 views

How can I use var php with javascript to build custom page? [closed]

is variable increment in $post_per_page = 10 if click on button next I can increase $Post_per_page = by_call <button type="button" value="increment++" >Increment </button&...
0
votes
0answers
13 views

How to show post gallery thumbnails in attachment page?

I want to show image gallery thumbnails in attachment page from the post. get_post_gallery images not working in wordpress. look like this
0
votes
1answer
19 views

Add a word to the first // wp_get_attachment_url // as the subdomain name

We use this code to display the link ... $mp3Link = wp_get_attachment_url($mp3_file_id); <a class="w3-black" href="'.$mp3Link.'" rel="nofollow" >mp3</a> It ...
1
vote
0answers
11 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
0
votes
0answers
34 views

How to download remote images?

I have a plugin that checks if the post contains external images and if so it will download and replace it with a local image. Now the problem is it doesn't download images if the image tag is written ...
1
vote
0answers
9 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 ...
1
vote
0answers
65 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' =&...
0
votes
1answer
35 views

Attachment pages stealing page slugs

I'm working on remaking a big website with its upload folder already full of many gigabits of images. I just noticed a problem I never noticed with WordPress before: it seems to create attachment ...
0
votes
0answers
49 views

How do I set the browser icon on a PDF viewed with the browser's built-in PDF.JS library?

I have uploaded PDF files to my site to allow visitors to view those PDFS. When the visitor clicks on the link, the PDF is displayed in a new tab with the browser's default PDF Viewer (which seems to ...
0
votes
0answers
250 views

Custom image size not displaying with wp_get_attachment_image()

I created a custom image size for my portfolio thumbnails add_image_size( 'gallery-thumb', 240, 180, true ); I created a shortcode to display all images using a lightbox with lazy loading to ...
0
votes
1answer
46 views

What are the meta fields for an attachment?

I'm trying to find all the meta fields that are used for an attachment: like Title, alternative text, description and caption . I've looked all over and the only one I was able to find was for an ...
0
votes
1answer
201 views

How to update an image attachment's alt text from a custom field when saving a post?

I created a block that has an image field and three text boxes: a textfield for the image alt, a text area for the description and another text field that was created in ACF to allow for photo credits ...
0
votes
1answer
799 views

Attach pdf from dynamic url

When I save a custom post, I would like to send a PDF by email as attachment. I tried that : function my_custom_save_post( $post_id, $post, $update ) { if( ! $update ) { return; } if( ...
0
votes
1answer
911 views

Call to undefined function wp_generate_attachment_metadata()

In content-attachment.php I have: /* preview for PDFs*/ if ('' === $ai) { wp_generate_attachment_metadata( $the_ID, wp_upload_dir() ); } And it throws this error: Fatal error: Call to undefined ...

1
2 3 4 5
20