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.

learn more… | top users | synonyms

1
vote
1answer
8 views

Update attachment metadata fails

Updating attachment title and description metadata with wp_ajax breaks all previous datas and structure of attachment, my php code: add_action( 'wp_ajax_update_attachment', '...
0
votes
0answers
14 views

Problem uploading multiple images to a custom field in a front-end form

I'm having trouble with a portion of a front-end form that allows users to create posts in my custom post type. I want to create an image uploader that will allow the user to upload multiple images. ...
1
vote
1answer
37 views

Use Timber/Twig to pull an image by image ID [closed]

Is it possible to use Twig to pull an image by ID, or only to pull the post.thumbnail? The Twig docs don't seem to cover any other image need and I'd like to specify a backup image in case no post....
1
vote
0answers
44 views

Searching Custom Post Types

I am trying to create a search template to search attachments uploaded to a custom post type called folders. This is what I have so far: if ( $post->post_type == 'attachment' && $post-...
1
vote
2answers
55 views

How to upload image from front end and save in media library?

I am working on a plugin .I want to upload image from front end i.e by input type="file".I did lot of google for it but could not upload image .Here is my code for uploading image <form method="...
0
votes
0answers
11 views

Query by attachment image size

Is it possible to use WP_Query to get attachment images by pixel size? For example all images with a width of 500px and height of 300px. Or images with a height bigger than 300px. As far as i can ...
0
votes
1answer
31 views

Add custom field to attachments in a specific category

I have a working function that adds a meta field to all attachments (so I can enter the url of a video). I would like this field to populate only on attachments in the "video" category. I've tried ...
0
votes
1answer
51 views

How to add a caption to an image attachment in a file list?

I've tried various things and can't get the captions to show up in my gallery. I'm using CMB2's file list to output image attachments. I hope this question is pertinent enough to this forum as I think ...
1
vote
0answers
16 views

Images attached to posts from library link to 404 error page

Just building a theme but I am stuck with attachment images. When I add images from the library to posts (or pages) and link them to the "attachment page" I get a 404 error. The link is like "http://...
0
votes
1answer
23 views

Could not get attachment using wp_mail

I am trying to create a form which can be sent by users with an attachment. The form works fine and sending the emails when it is submitted but without the attached file. my form is : <form ...
0
votes
0answers
27 views

Exclude Featured Image Attachments from Wordpress Search Results

I'd like my search.php page to show all attachments except featured images (because they appear as duplicates of the posts that use them). I have seen some examples that do this for a query, but can'...
0
votes
1answer
27 views

How to get the filename from file system and create a download link?

I have a custom page template. This template have a custom form, the user can upload a file in that form and input his/her personal infos. The file will save in the file system. I want to create a ...
1
vote
0answers
24 views

Posts and Attachments with “Published” status in Search

I would like the search to show only published posts and attachments (the attachments are photographs taken directly from the media library). The trouble is, when I specify that the post_status must ...
1
vote
1answer
20 views

Wordpress Search Results for Multiple Post Types

I want to show both posts and attachments in the search results. Basically, I need something that says if the post has a thumbnail, show it. else show the attachment image (since they don't have ...
0
votes
1answer
20 views

How to set an attachments parent post id in code?

I've inherited an imported wordpress site with a few issue. I have a list of attahment ids and post ids but I need to re-connect them in the code. I've got a list of all attachemnt like this: $...
0
votes
1answer
53 views

Get Attachment Category Name

How can I call the name of an attachment category? Something that would look like <?php get_attachment_category_name ?> or $attachment->category_name This would simply output the name of ...
0
votes
1answer
24 views

Attachment Metadata inside of Loop

Basically, I'm trying to call attachment info to display withing a loop, for use in an image gallery. I know I need to use wp_prepare_attachment_for_js($attachment_id) but I can't seem to get anything ...
1
vote
1answer
17 views

Attachment changing page's permalink - $post not resetting?

I have a function that I use to populate from checkboxes on a page's edit view (post.php?action=edit). I call this function when I render a metabox on the editor page. function ...
0
votes
2answers
38 views

Using $_FILES variable into the same function for uploading images and files

I want start saying that I'm learning and I'm trying to understand the use of $_FILES and $file_handler which are making me crazy into this function to upload attachments from a frontend form. What ...
0
votes
2answers
48 views

Upload images and attachments from frontend form

I'm not very expert of wordpress and I'm trying to create a frontend form sending information to my php function through ajax. I'd need help about uploading images and files as attachments of the post....
4
votes
1answer
51 views

Validate alt text for attachments?

How can I require users to enter alt text when adding attachments? Alt text is surprisingly buried; the only way I've been able to retrieve the alt text at all is via the wp_get_attachment_image() ...
0
votes
0answers
25 views

Encoding error when importing blog to new website

when I import my old blog (OLD) content to a new website (NEW), it messes up the file names in the uploads folder (more specificaly, it turns images containing special characters like "Capture-d'écran....
0
votes
0answers
14 views

Basic HTML visual editor for image captions

So, Wordpress 3.4 and beyond now allows html within the Caption field of an image. However, there isn't the basic visual html editor attached to the field. Is there a way to turn on the basic html ...
0
votes
0answers
12 views

Change permalink to attachment gallery post and redirect parent post

I have a problem with the photos attached to another article Example: **Photo1** attached in MyPost1 **Photo2** attached in MyPost2 **Photo3** attached in MyPost2 **Photo4** attached in MyPost3 **...
0
votes
1answer
24 views

Attachments plugin cannot click media library button [closed]

I have installed the Attachments plugin (version 3.5.7) to upload multiple images to a post in my post type 'shop'. The problem: For some reason I cannot click the insert button of the media library ...
0
votes
1answer
20 views

Help to upload post attachments from Ajax

My problem is that I cannot upload post attachments from a frontend form. I send data through AJAX to my php files containing functions. Let me be clear: everything is working great, the post is ...
1
vote
0answers
28 views

Get attachments for posts that belongs to a specific category

I am trying to get images which are used by a post belonging to the specific category. For example if I have plants, mushrooms and animals as post categories, I only need to retrieve images that are ...
0
votes
0answers
10 views

find uploaded files withouth a corresponding attachment in DB

We have a site with an upload directory that it's in a mess. There are thousands of files that exist on disk, but that don't have a corresponding DB attachment. At the same time, there are many ...
0
votes
1answer
23 views

Search by Attachment ID

I'm building a stock photo page for my company where we upload all photos our staff created so that it can be used later. It shows the ID of the image by post->ID so that users can see it, note it and ...
5
votes
1answer
121 views

Add custom class to attachment in media library grid mode

In the above screenshot we are in the media library with grid mode active. I want to add a custom class depending on the attachment filter wp_prepare_attachment_for_js. For example i hook to the ...
0
votes
2answers
40 views

Looking to limit file attachment downloads

I am using WP user front end plugin to let users submit posts to my site that includes a file on that post that other users can download. The problem is I want user-a to only be able to download a ...
0
votes
0answers
28 views

how to prefix image file name with 0001a, 0002b, 0003c and so on

Please look at the code below: var randomstring = (Math.random() + 1).toString(36).substring(7) + n; It creates a random characters + numbers combination to the image while renaming it. Original ...
0
votes
2answers
46 views

How to get Attachments(image) with specific width\height ratio

I need to get attachment images with horizontal orientation. I tried to use Meta_Query but I don't know how to compare two values (width and height) from one associative array that is in wp_postmeta ...
0
votes
1answer
85 views

Get post embedded image caption

I am trying to get the caption of post embedded images to then use on a lightbox. This is my code: function my_theme_prefix_content_gallery( $content ) { global $post; $args = array( ...
0
votes
1answer
21 views

Attachment file display link text

This is driving me slightly demented. It's taken me a few hours to work out how to do this and I thought I finally had it, but the link text will only echo the file name and not the link text I want ...
0
votes
0answers
92 views

add attachment-filters on custom modal-media insert

how can I do to have the attachment-filters menu in my upload window? my upload wordpress deafult upload console.log("enqueque on metabox.php - media3.js"); openMedia = { data: false, v: ...
0
votes
0answers
25 views

Add text to wp_get_attachment_image_src

I am calling the thumbnail image this way: <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 300,300 ), false, '' )...
0
votes
2answers
55 views

How to change _wp_attachment_metadata specific value in SQL?

i had to resize a lot of existing images in my upload folder (around 1k). After reuploading them, Wordpress of course, doesn't recognize the new dimensions. My approach was to just change the size in ...
0
votes
0answers
41 views

Upload media via PHP

I'm trying to upload an image to the media-section, that is uploaded as dataurl to the server. I already have the image written into the database and uploaded to the most recent uploads subfolder. ...
0
votes
1answer
15 views

Limit attachment caption characters

I want to limit the characters a user is able to enter for the image/attachment caption. There are already long captions in the system and I don't wont to touch them. Any ideas on how to do this? I ...
0
votes
1answer
25 views

Troubles with code for upload a image

can someone give me please a code for image upload ? i try many but no one works , this is what i have : $post = array( 'comment_status' => $comment_status, '...
0
votes
0answers
65 views

Featured image does not work with images on a post at the frontend?

[Found a partial solution] I need a little help with this problem. I don't know why on my videos the theme uses a thumbnail and set it as featured image but for images it does not. When I install a ...
0
votes
0answers
22 views

Use audio file like image featured

Attempt to get the url of an audio file in post content to display in the loop of the home page. I can only get it if the file is uploaded at the time of creating the post, but if I go to a post ...
0
votes
0answers
34 views

Avoid Duplicate Attachment By Numbering Duplicate post title Wordpress

Hello friends i am running an wallpaper site with WordPress, There are i have more than 2 thousand images recently i get duplicate attachment title issue in webmaster. So i want to numbering duplicate ...
0
votes
0answers
14 views

wordpress gallery captions

I'm trying to develop a simple content site with wordpress which requires a slider gallery with unique captions for each image within the gallery. $gallery = get_post_gallery_images( $post ); Using ...
0
votes
2answers
73 views

wp_get_attachment_image not to get the post_thumbnaill

I have a setup, where I want to achieve that I have a big Picture of a product (Post-image), and then below a list of other thumbnails, which can be opened in a Lightbox. I made this, by querying the ...
0
votes
0answers
14 views

How to compare 2 attachment tags against category tag

I need to compare 2 tags from an image attachment against tags that are used in categoryID=2. And only get returned the tag that is used under the categoryID=2. With that, I should get returned just 1 ...
0
votes
2answers
38 views

Link FROM attachment to full post and get custom fields values on attachment page?

This shouldn't be so hard! But I cannot find the answer to this question on Google.. How can I link from an attachment template to the full post please? Bonus question! How can I grab the custom ...
-1
votes
1answer
57 views

How to force regenerate thumbnails in Wordpress posts?

We recently changed themes. The new theme uses different dimension thumbnails and I was a bonehead and deleted all previous thumbnail sizes. Deleting the thumbnail sizes results in many of the images ...
1
vote
0answers
42 views

Attachment page 404

After I uploaded some files into the Media Library, I clicked "View attachment page" in "Attachment Details", but I got a 404 not found error. The URL is like http://example.com/filename/ and there is ...