New answers tagged

1

The code below will only run once whenever a file is uploaded. We keep an array ( $image_mimes ) of acceptable image-mimetypes We get the current attachment mime type We make sure what is given is indeed an image ( because we don't need unnecessary postmeta cluttering our table ) We grab the title from the attachment and set it to the alt-text initially ...


0

Everybody has been very useful and I say THANK YOU guys for having helped me out. The problem seems really to be into $_FILES variable which overwrite itself throughout 2 loops. After several tries I've found this solution that works for me and allows to upload both images and files. if ($_FILES) { // I've firstly declared main variables ...


0

I did override something. I did not validation and only build structured to validation and upload function. You can validate file as you needed. if ($_FILES) { // Get the upload attachment files $images = $_FILES['moreimages']; $errors = ''; foreach ($images['name'] as $key => $value) { if ...


0

If you are not very familiar and want a plugin that can do all that for you using drag and drop, try WP-TYPES and their CRED plugin. Just don't mind their support, it's really frustrating.


2

I mentioned in a comment how it's important to debug your code. Here's why: The images are added first. In the image adding section, you're running this line of code: $_FILES = array("moreimages" => $image); Then when you get to your routine that adds the files, you start with this: $files = $_FILES['morefiles']; Can you see what's wrong here? At ...


0

After checking other browsers, I found out that it was a Chrome problem. It looks like it has something to do with Google Chrome notifications. I fixed the problem with adding this CSS to my WordPress admin css file: /* Chrome media library upload button fix */ @media screen and (-webkit-min-device-pixel-ratio:0) { .modal-open .rdr-notifier { ...


0

I've actually forgotten to create the function for uploading and attaching images. I've found the correct method into another question here Uploading Multiple Attachments From Front-End With A Description.


1

The WP_Query class can match IDs as well as search terms. An idea would be to use the pre_get_posts action to detect if the search term is numeric and, if it is, set the query to work with attachments while passing the search as the ID. function wpse223307_allow_search_by_attachment_id( $query ) { //Only alter the query if we are in a search screen,... ...


4

The classes added to each element in the media library grid are dinamically generated in the media-views.js file. Particularly, the code that renders the elements is part of the wp.media.view.Attachment function. It's a Backbone.js view, so it's possible to extend the library of that view in order to add the classes or other attributes you need to the grid ...


0

If your attachment is handled via the WP media library, each one has unique ID, just like Posts. When your users download the attachment by clicking the button, store a reference to that attachment ID in a user_meta setting and then update the button accordingly. Another option: https://easydigitaldownloads.com/


1

Perhaps your question no so much clear regarding your issue.I give the solution which i have understand the above question. 1. Define a query variable that indicates the requested file function add_get_file_query_var( $vars ) { $vars[] = 'get_file'; return $vars; } add_filter( 'query_vars', 'add_get_file_query_var' ); 2. Update .htaccess to ...



Top 50 recent answers are included