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
10 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
27 views

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

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
17 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
9 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
21 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
24 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
13 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
21 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
79 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
27 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
59 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
125 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
209 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
33 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
39 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
46 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
15 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
22 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
14 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
60 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
42 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
35 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
66 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
33 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
46 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
30 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
36 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' ); ...
0
votes
1answer
111 views

Frontend AJAX Media Upload returning 404

I am building a custom registration form for users where they have to upload an image of government ID. Using AJAX for submission. The handler function always returning a 404 status error, no matter ...
0
votes
0answers
16 views

Error 503 with wp_delete_attachment

I´m doing a plugin which must do an import from an api. Inside this import, I have to removed phisicaly pictures before saving new ones. For some reasons this line code wp_delete_attachment( $...
0
votes
0answers
38 views

How to upload an auto-generated URL Screenshot in a User Submitted Post?

I have a form that allows users to submit a post, and one of the fields is a URL. I would like the form to submit that post, and also upload a screenshot of the URL that is generated by the code. I ...
1
vote
0answers
13 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 ...
0
votes
1answer
50 views

How do I add html content to custom post type Posts using php?

I'm trying to do something that I'm sure is very basic, but I can not figure out how to do it. Here's the setup: I used the CPT UI plugin to create a custom post type called board_docs, and I used the ...
0
votes
0answers
111 views

How to enable Attachment post type in Gutenberg editor for blocks?

I would like to make the native Attachment posts to be accessible by various Gutenberg Blocks. (To appear & be selectable in dropdown menus, etc.) Is that possible? The nearest answer i found is ...
0
votes
0answers
16 views

Can't identify why code can't get attached images thumbnails urls

In my functions.php i'm trying to get the 'small' (thumbnail) urls of all the images attached to a post: $post_id = get_the_ID(); $images = get_post_meta( $post_id, 'user_images_upload' ); ...
0
votes
1answer
145 views

SQL: How to find all attachments that are not used in any posts/pages/custom_post_types

I have a wordpress installation where the posts also contain attachments that were not embedded in the content by using the media library -> add. I would like to find all attachments that are not ...
0
votes
1answer
37 views

How is it possible that a gallery doesn't have attachment ids?

I have a function that looks at the attachment IDs from a normal gallery (let's ignore Gutenberg galleries for now, they have a different structure altogether): \get_post_gallery( 0, False );, this ...
0
votes
1answer
24 views

Change attached img anchor link to post link

When I attached images, it nested in this hierarchy of html tags : <div id="attachment_ID" class="alignnone"> <a class="image-ID" href="https://image-link.jpg"> <img class="...
2
votes
0answers
40 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
96 views

Get PDF in media by ID

On my search page, I've added all the file from the media with this code : function attachment_search( $query ) { $args = array( 'public' => true, '_builtin' => ...
0
votes
1answer
56 views

Attachment URL for an image is loading direct image file

I'm working on a site that is using a theme with an attachment.php file in the theme. However, when going to an image's attachment page (i.e. https://domain/john-doe/) it loads the direct image (i.e. ...
0
votes
1answer
19 views

Append Media/Attachment IDs to Gallery Shortcode HTML Output

I've been trying to find a simple and elegant solution to append the media/attachment IDs to my [gallery] shortcode html output. I've seen various functions to rewrite the whole output of the [gallery]...
0
votes
0answers
28 views

attachment_fields_to_save first parameter is null

I have the following code in a self-written plugin. In the function saveHomepageGalleryCheckbox the first param ($post) is always null. Did I something wrong? The second parameter ($attachment) has ...
0
votes
0answers
18 views

Media attachment page - custom URI, and trying to display differing links, based on that URI

I'm trying to edit the "media attachment" template. I have four image galleries, each one with a different URI. I want the media template to reflect the gallery in a link in the page. The media ...
1
vote
1answer
253 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 ...
0
votes
1answer
36 views

Attach and retrive multiple pdf files to post or page

I need to create two sections that will respectively contains only some pdf to downloads. I've never used pdf inside a wordpress websites, my question is how I can display them or in any case had a ...
0
votes
1answer
30 views

how to redirect 404 to attachment.php?

I have a problem, I have many url attachments with / amp, example: siteweb.com/article-2019/image2/amp siteweb.com/article-2019/image3/amp siteweb.com/article-2019/image4/amp all these give me 404 ...

1
2 3 4 5
19