Loop through child images of a parent for a Nivo Slider

To get attached (i.e. child) images of a post, try using get_children(). e.g.: <?php $child_image_args = array( ‘post_mime_type’ => ‘image’, ‘post_parent’ => $postID, ‘post_type’ => ‘attachment’ ); $child_images = get_children( $child_image_args ); ?> Which returns an associative array of child images. Then, just loop through them, e.g. using wp_get_attachment_image(), to output. e.g.: <div id=”nivoslider”> <?php … Read more

Open the attachment details modal

Unfortunately the logic of the attachment details isn’t made to be used standalone – it requires the grid that opens it. You can however use the get_media_item( attachment_id ) method to receive the HTML of the form for modifying images: https://developer.wordpress.org/reference/functions/get_media_item/

Adding custom image size to the media image editor

As far as i know it is possible with image_size_names_choose hook (see https://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose). Example: // add your custom size function my_setup_image_sizes() { add_image_size( ‘wide-image’, 900, 0); } add_action( ‘after_setup_theme’, ‘my_setup_image_sizes’ ); // add custom size to editor image size options function my_editor_image_sizes( $sizes ) { $sizes = array_merge( $sizes, array( ‘wide-image’ => __( ‘Image 900px … Read more

Is it possible to prevent users from uploading small images?

Here you go: if(!current_user_can(‘delete_others_posts’)){ /*Handling wp media uloads*/ add_filter(‘wp_handle_upload_prefilter’,’lets_handle_img_width’); function lets_handle_img_width($file) { $img = getimagesize($file[‘tmp_name’]); $width = $img[0]; if ($width < 350){ $file[‘error’] = “Image is small too small. Get something of width more than 350px.”; } return $file; } } Check official documentation about wp_handle_upload_prefilter.

Can images be automatically compressed?

Use http://wordpress.org/extend/plugins/auto-image-resizer/ Add this to your functions.php: function prune_image_sizes($sizes) { // You can add other size like that for remove those sizes // unset($sizes[‘medium’]); unset($sizes[‘large’]); return $sizes; } add_filter(‘intermediate_image_sizes_advanced’, ‘prune_image_sizes’); Set your large image option to 800px in media options panel. So what did you do? System will not create large size of image but … Read more

No srcset for hard-cropped thumbnails

To show a srcset, there must be multiple image sizes of the same aspect ratio. When you set your thumbnail to hard crop without creating any other image sizes you are ensuring that there won’t be a srcset. You might find my answer here helpful. Briefly, in your case, adding this line: add_image_size ( ‘double-size’, … Read more

Alter image output in content

Your better off adding your custom image data when you insert it into a post using media_send_to_editor, the caveat is this will not be applied to any existing images, only ones inserted after adding the function. To apply it to to existing content you will have use preg_match on the_content filter, but this can significantly … Read more

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