New answers tagged

0

Haven't tested it, but this should work: // check for file upload size // { if( !current_user_can( 'administrator') ) add_filter( 'wp_handle_upload_prefilter', 'mdu_validate_image_size' ); } add_filter('wp_handle_upload_prefilter','mdu_validate_image_size'); function mdu_validate_image_size( $file ) { if ( mime_content_type($file) == 'application/zip' ...


-1

Here yet another approach: Its hooks into the 404 HTTP error handling. That is, when thumbnail is not available, find the original image and create the thumbnail. Note that this does not really solve your problem, as it does not preven thumbnail generation during upload. Note also that this plugin might be used by malicious users to create any number of ...


0

I've build a function to get the ID from DB, searching by URL. function get_attachment_id_from_src ($image_src) { global $wpdb; $query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$image_src'"; $id = $wpdb->get_var($query); return $id; } You can get URL (insted of html code) with a fourth paramenter set to 'src' Codex: ...


1

That's the same media manager. The first image is what you see if you try to put a gallery into your page or post. The second is what you will see if you add a Featured Image, where the gallery tab would not be relevant.


1

as per chat discussion, once you get the attachment ID you can get the url using wp_get_attachment_url($attachment_resume_id) so in your case you have to wp_get_attachment_url($record_s->attachment_resume_id)


1

There is no plugin for that as far as I know. The best solution for this would simply be to convert your pngs to gifs somewhere online, you have a lot of converters, and also bulk converters that may help you. Try this one I hope this helps.


2

If I understood correctly the situation described in the question and its comments, the user has capabilities to upload files and to edit your post type, so you shouldn't be fitering capabilities, the user already has the correct capabilities. The problem is that wp_editor() use the global $post by default, and in your context the global $post is for the ...


0

If you want to allow user to upload files. edit_post is wrong cap to check. Instead you will need to add cap upload_files to users and check against it. If you want to allow only images you may custom filer the allowed MIME type. See more at https://codex.wordpress.org/Roles_and_Capabilities#upload_files


2

Implementing your own upload form like this can be a major security vulnerability, you might want to instead use a library/script where such potential issues are already dealt with properly. Here is one I remember using successfully on a project for a similar purpose (user uploaded video)... though it may be more than what you need, it does have more ...


1

Well I was privileged enough to get the tumbleweed badge for this question. But I found the answer. Easy enough. Custom Upload Dir Plugin. Perfect for the job. Well, almost. With a little tweaking.


0

I found it :D Yeeeeeeeeaaaahhhhhh :)))) This is final code that worked! I explained each level ;) /* for get author ID use these */ $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); $author_id = get_the_author_meta('ID'); /* First condition */ if( get_the_author_meta('management_certi', ...


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 ...


1

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 ...


-1

try inserting image url on wp_posts table. use url as guid and post_type : attachment.


1

The Add From Server plugin actually was my answer. I just didn't know how to use it when I ran across it at first. When you click or hover on the WordPress Dashboard on the left over 'Media' you will see 'Add From Server' navigate through your directories and choose which file(s) you'd like to add. Found that information from here: ...


1

I had 2 things wrong: I unregistered wordpress's jquery without properly registering my own (I concatenated my scripts ) I didnt have wp_footer() in my theme. the wp_enqueue_media() function loads the scripts to the footer.


1

This is impossible to do (or at the very least not easy). The way the uploading process works is that first you upload a file to the media library, and only after the file is in the media library you may associate it with a post. The usage of the media library is mandatory if you want to use the media workflow, and you are more likely to break something ...


1

If you have successfully uploaded the theme via FTP into the correct directory it should be available to activate. Things to check: Using your FTP client, you should be able to see the theme directory and all its files under wp_content/themes Make sure the file permissions are correct for WordPress to be able to access the files (you may need to check ...


2

You need to use Open Graph meta markup to have this type of sharing on Facebook .There are so many plugins available in the WordPress repository for this. For example: <meta property="og:url" content="http://sharing/url" /> <meta property="og:type" content="article" /> <meta property="og:title" content="Title of the post" /> <meta ...



Top 50 recent answers are included