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
0answers
17 views

Removing existing attachment permalinks

I have recently migrated a site to another WordPress install by exporting data from the old site into XML and re-importing it to my new site. However, now, all of the attachments were assigned a ...
0
votes
2answers
20 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
12 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
15 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
20 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
44 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
11 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
15 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
20 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
17 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
29 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
13 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
38 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
14 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
21 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
58 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
10 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
6 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
13 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
11 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
10 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
25 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
37 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
17 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
28 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
150 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
30 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
89 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
410 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
436 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 ...
0
votes
2answers
34 views

Reinstall Wordpress while keeping attachments

I have a Wordpress installation that I want to reinstall. However, I also have in it several uploaded files (.doc and PDFs) that are linked by external sites. They are not used in any of my own pages: ...
0
votes
0answers
115 views

Image srcset returns false for some images + Image Sizes missing from attachment

I have a weird issue going on in WordPress at the moment. Some images does not return any image sizes, and when using wp_get_attachment_image_srcset it simply returns false. I have no idea why this is ...
0
votes
0answers
66 views

How can I remove the 'File URL' field from the image attachment editor?

When you go into the Media Library and select an image to edit, its associated 'Attachment details' page appears. On this page, there is a 'File URL' field which details the attachment file's URL. ...
0
votes
0answers
24 views

Exclude image from cloudflare hotlink protection

I am want to exclude my newsletter images from Cloudflare's hotlink protection Based on Cloudflare's documentation, it is possible to do this with serving the image from a "hotlink-ok" ...
0
votes
1answer
28 views

Custom attachment function not working in v5.4.2?

I have a function that I re-use in a number of custom themes when required to fulfil a customers need. I understand this can be achieved now with repeaters in ACF Pro but as I had a working function, ...
0
votes
0answers
22 views

display post pdf attachments in side bar with link text

I have a widget that places links to pdf attachments in the sidebar. I want to use the pdf attachment text heading (that is used to display it in the parent post) as the title. I cannot get this to ...
1
vote
1answer
61 views

Randomize attachment IDs

I'd like to have my attachments IDs being random (not sequential). Just like what this plugin does, but for attachments. I've tried to look into the source code of the plugin, but it uses filters that ...
0
votes
0answers
79 views

srcset shows original image url only

My website's post thumbnails shows urls as original url only, as shown in the next example: <img width="450" height="450" src="https://example.com/wp-content/uploads/2020/...
0
votes
1answer
64 views

Custom field in media library not saving, selected() function not adding “selected” to select list input type

Following the approach in the developer docs for selected() but can't get it to work with a custom field in the media library for a select list. It won't save the value, or become "selected"....
0
votes
0answers
9 views

How to search posts with specific attachment?

The wordpress backend only provide function to check single post attached. Is that possible to query posts that when the attachment inserted in multiple posts plus with multiple post type?
0
votes
1answer
31 views

Need clear explanation about medias/files/attchments

During an import, I need to add images and linked to a custom post using WPML like : post 1 in french 1.1 picture foo.jpg (visible in library and attached to this post and add as featured image ) 1.2 ...
0
votes
0answers
69 views

Programmatically Altering Gallery Link and image size?

I am in the process of implementing a new template on a site that I manage. part of that migration includes changing the embedded Galleries link setting from file to the attachment page. I've looked ...
1
vote
0answers
43 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 ); ...
0
votes
1answer
99 views

wp_insert_attachment() dupplicate attachment posts

I made a function to add an image in WP and attach it to the right post. The specificity is the input is an url to get the picture. My problem is when wp_insert_attachment() is run I got a dupplicate ...
0
votes
2answers
31 views

How to echo images Urls from a wordpress post, that are relally in the post

I have a question. I use the following code to output the image URLs of a wordpress post. The image URLs are related to the "attached images" of a wordpress post and not the ones that are ...
0
votes
0answers
39 views

Front-end upload image, no image preview in media

I have form to upload image via Ajax, it's works efficiently. But image not have preview thumbnail like : if(isset($_FILES['file'])) { require_once( ABSPATH . 'wp-admin/includes/image.php' ); ...

1
2 3 4 5
20