How to retrieve a value from an input field in a media view template

After digging through the media modal code, I came up with the answer to my question: wp.media.controller.Custom = wp.media.controller.State.extend({ initialize: function(){ this.props = new Backbone.Model(); }, // called when the toolbar button is clicked customAction: function( controller ){ // get the value of a media view template form field using // this.props.get(‘key’), where ‘key’ is … Read more

How do I create a custom add media button modal?

You can inspire from this tutorial here: http://www.sitepoint.com/adding-a-media-button-to-the-content-editor/ For videos you can change the library type to ‘video’: function open_media_window() { var window = wp.media({ title: ‘Insert a media’, library: {type: ‘video’}, multiple: false, button: {text: ‘Insert’} }); } Hope this helps.

Why would media_sideload_image() not work locally?

Ah, this is silly, but it turns out there was a very obvious reason why media_sideload_image() wasn’t working. My wp-content folder had the wrong the permissions from when I transferred it to my local environment and I wasn’t able to upload anything. Changed the permissions and it’s working fine.

Filter Media by Featured on Admin

We can add the Featured option as a fake mime-type with: add_filter( ‘media_view_settings’, function( $settings ) { $settings[‘mimeTypes’][‘wpsefeaturedimage’] = ‘Featured’; return $settings; }); It will show up like this: Then we can use the posts_where filter and check for our fake mime type: /** * Filter for featured images in the media library popup */ … Read more

Cannot embed YouTube videos “Failed to embed” error

This may be due to a failed network request from the server to youtube. If the server cannot reach YouTube, the embed will show as “failed to embed” in the editor. You can fix the problem by allowing the server to make network requests to youtube. The WordPress Proxy documentation may be helpful, https://developer.wordpress.org/reference/classes/wp_http_proxy/ WordPress … Read more

pass query string on url to filter media

As per the given url http….url…/author/name?MediaTag=tag1, below code may helpful… if(isset($_GET[‘MediaTag’])) //It will check the value of MediaTag (from address bar after ?) { $tag1 = $_GET[‘MediaTag’]; //Assigning value of MediaTag to the variable if($tag1) //Checking if variable have some value or not { query_posts(‘cat=1&author=” . $post->post_author . “&order=DESC&tag=’ . $tag1 .’&posts_per_page=12′ . ‘&paged=’ . … Read more

How do you use WP slugs for PDF files / media?

In my opinion it is best to add an endpoint of the form mysite.com/pdf/<id> or something similar to your like. That way you avoiding attaching the attachments to posts/pages or create a page for each pdf file with is redundant imo for your needs. This is a very small and basic guide. You can modify … Read more

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