Patch submission: get custom image size from system
-
I noticed the widget does not propose to size the image according to the system’s custom image sizes. In the source code you even complain about it °-)
Well, it was ennoying me too, so i looked around and it turns out there is a global var that contains all that you wish for:
Try echoing this
print_r($_wp_additional_image_sizes);
to see it for yourself.so, the patch:
1./ in image-widget.php, add a line at 163:
global $_wp_additional_image_sizes;
2./ in views/widget-admin.php line 40: remove
$possible_sizes = apply_filters( 'image_size_names_choose', array( 'full' => __('Full Size', 'image_widget'), 'thumbnail' => __('Thumbnail', 'image_widget'), 'medium' => __('Medium', 'image_widget'), 'large' => __('Large', 'image_widget'), ) ); $possible_sizes[self::CUSTOM_IMAGE_SIZE_SLUG] = __('Custom', 'image_widget');
and replace line 50 with:
foreach( $_wp_additional_image_sizes as $size_key => $size_label ) { ?> <option value="<?php echo $size_key; ?>"<?php selected( $instance['size'], $size_key ); ?>><?php echo $size_key . ' ('.$size_label['width'].' x '.$size_label['height'].')'; ?></option> <?php } ?>
That’s it, it works for me, and hopefully for you and your users too!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Patch submission: get custom image size from system’ is closed to new replies.