Following up on this answer I'm trying to determine how to create a modal with completely unique menu items/content than the media modal. If you add a new state you can add a new menu tab and have it render the appropriate content when clicked. However, what I've found so far is that if you don't include the traditonal wp.media.controller.Library() states (for gallery, insert, etc) then the menu does not render at all and you are left with an empty …
I have a plugin I built that adds a custom media frame with the following: media_frame = wp.media.frames.media_frame = wp.media({ title: 'Select your images', button: { text: 'Use Image' }, multiple: false }); media_frame.open(); This produces a media frame that looks like this: Thus far, this has been all I needed, but my site uses Wordpress Multisite and I'm trying to add in the Network Shared Media plugin. However, Network Shared Media requires the media-frame-menu sidebar in order to access …
Here is the thing. I am using the WP media uploader on the frontend. What I need is to have it behave differently depending on a certain action. I am attaching the media in a specific custom post type single page. This is a small excerpt from my code. I'm using this to trigger the media library. var uploader = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function(e){ // Some code here }); Then I am filtering the library …
I have a custom post type archive that has articles that call some ACF content on each post. I've used WP_Query to pull these articles onto the archive page, and there's a button in each article that when clicked will open a modal window with images I've placed in an ACF repeater for the custom post. How do I call the modal window by that button without calling the other modal windows open? Here's my code for the archive page: …
I have add some image size like: add_image_size( 'custom-small', 600, 600 ); add_image_size( 'custom-medium', 1280, 1280 ); add_image_size( 'custom-large', 2560, 2560 ); and I have removed all the default sizes. Now the Media Library in the Admin panel is loading full image instead of medium. Is it possible to specify a custom size to use?
How do I delete or remove the word Delete Permanently in uploading files? I wanted to remove this permanently so that the users won't keep deleting files which are not supposed to delete. I use this code: .button-link.delete-attachment{display:none} But the problem of this, if the user uses the inspect element, they can just change it to display:block to show the delete button. Using CSS is not an option. Is there a function code here to remove this? Or where can …
I want to overwrite the default WordPress gallery shortcode with a custom one. This because I need to add a field that will contain an url for each image I want to add inside a gallery. I'm not sure how to proceed, but for now I wrote this prototype of the code I want to use for the shortcode, I'm not sure how to proceed for the custom link field. Also I need to understand how to open the media …
In a customized mediamanager (base versione 3.5) I would like to keep displayed the "select file" button even when some files are already uploaded in the album. Is there a simple solution?
I have a form on my front end that I'd like to call a media library modal, but I want the library accessed to be a specific MU subsite. I trued to switch_to_blog around the wp_enqueue_media function, but it is not pulling the media from the targeted site. Is there a way to achieve this? I don't see a setting the jquery call to initiate the modal but maybe I missed it? switch_to_blog( 2 ); wp_enqueue_media(); restore_current_blog();
In my plugin I need a media uploader exactly like the one you see when you select a post's featured image. I managed to do almost everything with this code: media_uploader = window.wp.media({ frame: 'select', title: 'Carica le foto', multiple: true, library: { type: 'image', search: null, uploadedTo: postID }, button: { text: 'Imposta come principale' } }); The problem is that I can't sort the uploaded images. If I click and drag the images in the media uploader, the …
After a successful insertion with Ajax of an entry I would like to see what the ID and url of that same entry is and show it in a modal window Any way to get that data? <script> ajax_url = "<?php echo admin_url('admin-ajax.php'); ?>"; </script> <script> $("#enquiry_email_form").on("submit", function (event) { event.preventDefault(); var form= $(this); var ajaxurl = form.data("url"); var detail_info = { post_title: form.find("#post_title").val(), post_description: form.find("#post_description").val() } if(detail_info.post_title === "" || detail_info.post_description === "") { alert("Fields cannot be blank"); return; …
How can someone restrict the images which appear in the v3.5 Media Library modal to only show those that are attached to a specific post id? I'm creating a front-end management template that allows multiple authors to edit any particular post, hence the need to restrict what is shown on a post-by-post basis rather than those uploaded by a particular user. The upload modal is based off of Mike Jolley's upload modal tutorial. It's been modified to look for the …
I have this code. $('.custom-browse-button').on('click', function(e) { e.preventDefault(); var wpMedia = wp.media.frames.file_frame = wp.media({ 'library': { type: 'image' }, 'multiple': true }); wpMedia.open() .on('select', function(e) { var uploaded_image = wpMedia.state().get('selection').toJSON(); // already done with select. console.log(uploaded_image); }); }); In ajax request there are these parameters in the method POST: action:query-attachments post_id:0 query[post_mime_type]:image query[orderby]:date query[order]:DESC query[posts_per_page]:40 query[paged]:1 I want to add something more fore checking and hooks. Example: my_filtered_user_id=3 OR media_width_eqm=1000 How to add these things in wp.media? Update: Now I …
I'd like to be able to add classes to oembed videos on the fly in the post editor. This way I could have some videos act like images and alignleft or alignright and have text wrap around them, while the default behavior would be to set the video full width of the containing element and act responsively on resize. I already have that default behavior working via this function and some CSS: // remove dimensions from oEmbed videos & wrap …
I am using Bootstrap 5 and modal is kinda tricky. Do you happen to know why the dialog is under the backdrop? I've compared the modal example on Bootstrap website and on my code. I haven't changed any positions, just added header color and adjusted padding. One solution would be using data-bs-backdrop="false" but I wanted to have a backdrop. Thanks!!
I am trying to get the new upload frame of the featured image used in the admin side, but the one used in the front is different. I will show you some screenshots: In the admin section when I click into the Add Featured Image I get this modal box frame: But when I click in the link of my front end I got this modal box frame instead: Here is the code used to create the form in the …
I'm trying to make a photo gallery page for all my photos in my post-gallery post and have a modal open when you click on the photos. In the page there will probably be almost 100 photos and i'm not sure how to do this in a good way without duplicating the code for the modal 100x. I have considered using plugins but i'd doing this as part of making my own website and learning developing wordpress themes so i'd …
There is a button in the frontend on the post page to upload images. How do I display attachments that are attached to this post in the wp.media frame? How to intercept wp.media's AJAX request for attachments to filter attachments by post ID? Here's what I have: function.php add_action('wp_enqueue_scripts','bla_bla'); function bla_bla(){ wp_enqueue_media(); wp_enqueue_script('bla_bla_bla','/script.js','',true); } script.js var wpMedia; var wp_media_post_id = wp.media.model.settings.post.id; // keeping the old post id $('button.upload').on('click',function(event){ // file upload button in post var btn = $(event.target); var postID …
tl;dr: Why does using media manager popup within a TinyMCE popup cause duplications of shortcodes? Is it my code or just the way life is? [Spoiler: It was my code] I've written a small plugin to create a visual editor button and popup that inserts a shortcode representing a "media object": image to right, text to left. In the visual editor you click the button, fill in the text in the popup, choose the image and hurrah: The shortcode is …
I have placed a media button as a post meta field to insert an image URL into a text field when Insert Into Page button is clicked. It works up to the point of opening the media repository window, selecting image and insert, however no value is passed to the input field. Expected result The result should be that the URL along with media ID are inserted as https://avalon.com/dev/wp-content/uploads/2021/01/scp7147prko31.jpg|12 but no value is returned. I can enter a URL manually …