Adding fields to the media uploader with jquery listeners

From Blackbone.js website: render is the core function that your view should override, in order to populate its element (this.el), with the appropriate HTML. The convention is for render to always return this. So, I have modified the code a little bit to add jQuery change listener. function add_gallery_type_option(){ ?> <script type=”text/html” id=”tmpl-my-custom-gallery-setting”> <label class=”setting”> … Read more

How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page

The current screen doesn’t appear to be set when that filter is run, so you cannot use that. Also, the $post actually refers to the attachment, not the post – so we can’t get the post typ fro that either…. So looking at the source code: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-admin/includes/media.php The filter you are using is called by … Read more

WordPress function: limit size, only jpg, jpeg, limit of uploaded files per account

You cannot check the image before uploading, as WordPress is a serverside script. However, before inserting the image in the Media library, you have different options, as I explained in this answer, with filtering wp_handle_upload_prefilter. In your case, the function filtering the wp_handle_upload_prefilter would be something like this: add_filter(‘wp_handle_upload_prefilter’, ‘f711_image_size_prevent’); function f711_image_size_prevent($file) { // get … Read more

How to extend Media Library (WP 4.4)

It’s not a tab but you might be able to get started with an upload button. Check out pre-upload-ui and some actions that follow. Namely pre-plupload-upload-ui and post-upload-ui. This will add a couple buttons to the ‘Upload Files‘ tab and to ‘Media > Add New‘. BUTTONS add_action( ‘pre-plupload-upload-ui’, ‘wpse_20160202_pre_plupload_upload_ui’ ); add_action( ‘post-upload-ui’, ‘wpse_20160202_post_upload_ui’ ); function … Read more

Restrict file uploads by extension?

I believe you can add a filter to upload_mimes to restrict to certain types. The hook: http://adambrown.info/p/wp_hooks/hook/upload_mimes The filter: add_filter(‘upload_mimes’,’restict_mime’); function restict_mime($mimes) { $mimes = array( ‘jpg|jpeg|jpe’ => ‘image/jpeg’, ‘gif’ => ‘image/gif’, ‘png’ => ‘image/png’, ); return $mimes; } From what I understand this will not work for admins or any user with the unfiltered_upload … Read more

Gel all image from certain post type

Try this code in your template. $query = new WP_Query( array( ‘post_type’ => ‘custom-post’, ‘posts_per_page’ => -1 ) ); if( $query->have_posts() ){ while($query->have_posts()){ $query->the_post(); $image_query = new WP_Query( array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘post_mime_type’ => ‘image’, ‘posts_per_page’ => -1, ‘post_parent’ => get_the_ID() ) ); while( $image_query->have_posts() ) { $image_query->the_post(); echo wp_get_attachment_image( get_the_ID() ); … Read more

categories on attachment page

If you have WordPress 3.5 this will work. http://make.wordpress.org/core/2012/12/12/attachment-editing-now-with-full-post-edit-ui/ First you need to enable this in your theme, Put this in your functions.php file in your theme root. add_action(‘init’, ‘wpse_77390_enable_media_categories’ , 1); function wpse_77390_enable_media_categories() { register_taxonomy_for_object_type(‘category’, ‘attachment’); } In your image.php or attachments.php file add: $tax = get_the_term_list( $post->ID, ‘category’ ); echo $tax; Then go … Read more

Create custom tab in WordPress 5 media upload

The only way I could get this to work in WP 5 was to install the Classic Editor. Then I could use media_view_settings to add the tab. add_filter(‘media_view_settings’, ‘addMediaTab’); function addMediaTab($settings) { $settings[‘tabs’] = array(‘mymediatab’ => ‘My Media Tab’); return $settings; } BUT it appears the new UI doesn’t include those sections in Gutenberg, you … Read more

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