Upload images from custom plugin using the media modal

Ah! The classic issue anyone that’s cared about their users’ experience has come to face. As per my experience, wp.media is the way to go. This is not my code, but it gets the job done. I’ve used it plenty. I’ll explain what it does, piece by piece: // Source: https://vedmant.com/using-wordpress-media-library-in-widgets-options/ jQuery(document).ready(function ($) { $(document).on(“click”, … Read more

How to let a user select a media from the media library

Similar question can be found here and here. I use the following method, adapted from here: When your theme/plugin initializes: wp_enqueue_media(); Handle the media dialog in Javascript: var wp_media_dialog_field; function selectMedia() { var custom_uploader; if (custom_uploader) { custom_uploader.open(); return; } custom_uploader = wp.media.frames.file_frame = wp.media({ title: ‘Choose Image’, button: { text: ‘Choose Image’ }, multiple: … Read more

How to change the image size in new Media Uploader (ie use medium vs thumbnail)

Supposing that I’m interpreting your Question correctly… The thumbnails displayed in the new Media Uploader are already the medium sized ones, being constrained on the fly. So, it’s a matter of applying some CSS styling to increase their size. Maybe other style adjustments are necessary, this is just a proof of concept. add_action( ‘admin_head-post-new.php’, ‘style_thumbnails_wpse_81677’ … Read more

Change Media modal image size

I don’t know of any good way to do that as the problem is most likely that the images are way larger than they should be. However, there are a couple of things that you could do to resolve the problem. First, re-size your images before uploading them if at all possible. For most applications, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)