How can I hide media library images from general users?

To let the current users only view his/her uploaded attachments, add the following code to your themes actions: add_filter( ‘posts_where’, ‘devplus_wpquery_where’ ); function devplus_wpquery_where( $where ){ global $current_user; if( is_user_logged_in() ){ // logged in user, but are we viewing the library? if( isset( $_POST[‘action’] ) && ( $_POST[‘action’] == ‘query-attachments’ ) ){ // here you … Read more

Change the output for [gallery] shortcode

The source for the gallery shortcode is in wp-includes/media.php. There are a couple of hooks in there that might work for you. Without knowing exactly what you want to do, it is impossible to be more specific. If that doesn’t work then you can remove the shortcode: remove_shortcode(‘gallery’); And add another gallery shortcode with the … Read more

Automating a Daily Picture Blog?

There are lots of ways to accomplish a daily picture blog so I’ll just give you how I’d approach it. If I wanted to set up a photoblog on WordPress I’d start with a Flickr account and leverage it (or if you don’t like Flickr for some reason you can also look at PhotoBucket, SmugMug, … Read more

Replace Woocommerce Images

Unfortunately, trying to pull a fast one on the WordPress media library with FTP won’t work. You’ll need to import them through the WP admin so they get added to the database, resized, and whatever other special sauce WP adds. I’ve never used it, but this plugin sounds like it might be right up your … Read more

Bulk edit wordpress images alt and title attributes

You can use the ‘wp_get_attachment_image_attributes’ hook add_filter( ‘wp_get_attachment_image_attributes’, ‘image_attributes’, 20, 2 ); function image_attributes( $attr, $attachment ) { // Get post parent $parent = get_post_field( ‘post_parent’, $attachment ); // Get post title $title = get_post_field( ‘post_title’, $parent ); if ( is_single( $parent ) ) { $attr[‘alt’]=$title; } return $attr; } Or Check Out my new … Read more

Theme Customiser Image Control

The solution, needs a custom control object extending the original image control, and does an SQL query to grab the GUID and associated attachment ID on sanitisation. Not nice, kludgey, but it works $wp_customize->add_setting( ‘customimage’, array( ‘default’ => $default, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, ‘sanitize_callback’ => array( ‘ICIT_Customize_Image_Control_AttID’, ‘attachment_guid_to_id’ ), ‘sanitize_js_callback’ => array( ‘ICIT_Customize_Image_Control_AttID’, … Read more

How to limit number of images being printer out in “Set Featured Image” pop up?

Update 1: After dived into core AJAX call, this filter will only happen on post.php page: add_filter(‘ajax_query_attachments_args’, function($query){ if ( isset($_POST[‘post_id’]) && !empty($_POST[‘post_id’]) ) { $query[‘posts_per_page’] = 10; // output 10 images only. } return $query; }); You can use ajax_query_attachments_args filter: add_filter(‘ajax_query_attachments_args’, function($query){ $query[‘posts_per_page’] = 10; // output 10 images only. return $query; }); … Read more

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