get total number of images from media using xml-rpc

VERSION 1 will query all the images and give you a count by checking the size of the returned array. VERSION 2 is a much faster method introduced by birgire. // VERSION 1 $images = get_posts(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘any’, ‘numberposts’ => -1, ‘fields’ => ‘ids’, ‘post_mime_type’ => ‘image/jpeg,image/gif,image/jpg,image/png’, )); echo count($images) . … Read more

Way to display media library in frontend

As far I’ve understood with those I’ve written a simple system for you. Please put the below codes in your functions.php– add_action( ‘wp_enqueue_scripts’, ‘the_dramatist_enqueue_scripts’ ); add_filter( ‘ajax_query_attachments_args’, ‘the_dramatist_filter_media’ ); add_shortcode( ‘the_dramatist_front_upload’, ‘the_dramatist_front_upload’ ); /** * Call wp_enqueue_media() to load up all the scripts we need for media uploader */ function the_dramatist_enqueue_scripts() { wp_enqueue_media(); wp_enqueue_script( ‘some-script’, … Read more

How to set additional parameter in wp.media?

I’ve been searching for this answer too and found it using this answer. You just need to add a property to the library object: var wpMedia = wp.media.frames.file_frame = wp.media({ ‘library’: { type: ‘image’, custom_var: ‘webhead’ }, ‘multiple’: true }); Then in PHP you can see the custom variable in the ajax_query_attachments_args hook like so: … Read more

Change default tab of media manager

Try this: function rearrange_media_tabs($_default_tabs) { $_default_tabs = array( ‘custom’ => __(‘Your Tab Name’), ‘type_url’ => __(‘From URL’) ); return $_default_tabs; } add_filter( ‘media_upload_tabs’, ‘rearrange_media_tabs’ ); From the Codex: https://developer.wordpress.org/reference/functions/media_upload_tabs/

Filter what image sizes get generated

Picking which image sizes to generate on a per-upload basis is definitely going to be a bit involved. However, if you’re okay with just entirely removing default image sizes, you have a couple of options, as described in this article: The simplest way is to set the default image height and width to ‘0’ at … Read more

Shortlink directly to a media file?

It turns out this is easily solved by creating a file attachment.php and redirecting to the file itself. Create an attachment.php file in your WordPress theme folder Put this code in the file <?php wp_redirect(wp_get_attachment_url(), 301); ?> Upload it and there you go This link explains in full.

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