[Plugin: WP Smart Image II] Determine if custom size exists? (2 posts)

  1. Michelle
    Posted 5 years ago #

    Hi and thank you for this wonderful plugin!

    I have integrated it with Max Image Size Control and have it working great.

    I would like to know if there's a way to check if a custom image size exists before inserting it in my template. I have tried this, on a site where the "custom2" size has never been specified in Max Image Size Control:

    $imgSize2 = get_wpsi('size=custom2');
    if($imgSize2 != "") {
      // code to display it
    } else {
      // code to display thumbnail

    But the check fails and returns the original (very large) size of the image.

    Any ideas on how to get this working would be much appreciated, thank you!


  2. Dario Ferrer
    Posted 5 years ago #

    Hi mmcginnis,

    The next version will bring this feature very improved. You'll love it ;)

    As you say, we can call the "custom2" size, but still lacks the # setting. So the query implies a little complex array. This is the code i'm using:

    if (class_exists('max_image_size_control')) {
    	$wpsi_misc = get_option('max_image_size_control_data');
    	$wpsi_misc = $wpsi_misc['max_image_size'];
    	foreach($wpsi_misc as $key => $misc) {
    	if($misc['everypost'])  $count += $misc['everypost'];
    		for ( $i = 0; $i <= count($key); $i++ ) {
    			if($misc['custom'][$i]['custom_size_w'] and $count == 1)
    			$formulario .= '
    			<option value="custom'. $i .'">'.__('Setting', 'wp-smart-image').' #'. $key .' &raquo; Custom'.$i.': '.$misc['custom'][$i]['custom_size_w'].' x '.$misc['custom'][$i]['custom_size_h'].'</option>';

Topic Closed

This topic has been closed to new replies.

About this Topic