Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • For people having issues cropping, have a look at this thread:

    http://wordpress.org/support/topic/plugin-scissors-continued-custom-image-sizes-arent-handled

    Ales’s solution appears to require the “Simple Image Size” plugin. Additionally, there seems to be a bug when “post-thumbnail” is a size option. Because post-thumbnail contains a hyphen, it’s causing a JavaScript issue when it tries to declare the variable because it’s not in quotes.

    I have modified Ales’s hack so that it doesn’t require you to install an additional plugin and fixed this post-thumbnail bug.

    First of all, I added the $_wp_additional_image_sizes variable to the global variable scope of the function.

    global $scissors_dirname, $_wp_additional_image_sizes;

    Now, when not dealing with standard sizes, it pulls the dimensions from the $_wp_additional_image_sizes variable.

    if (isset($_wp_additional_image_sizes[$size])) {
    	$width = $_wp_additional_image_sizes[$size]['width'];
    	$height = $_wp_additional_image_sizes[$size]['height'];
    	$aspectRatio = max(1, $width) / max(1, $height);
    	if(!$_wp_additional_image_sizes[$size]['crop']) $aspectRatio = 0;
    } else {
    	$aspectRatio = 0;
    }

    Finally, to fix the post-thumbnail JavaScript issue, I changed

    echo ",\n{$size}AspectRatio: $aspectRatio";

    to

    echo ",\n'{$size}AspectRatio': $aspectRatio";

    So the final function should look something like this:

    function scissors_admin_head()
    {
    	if(strstr($_SERVER['REQUEST_URI'], 'media'))
    	{
    		global $scissors_dirname, $_wp_additional_image_sizes;
    
    		wp_enqueue_script('scissors_crop', '/' . PLUGINDIR . '/'.$scissors_dirname.'/js/jquery.Jcrop.js', array('jquery') );
    		wp_enqueue_script('scissors_js', '/' . PLUGINDIR . '/'.$scissors_dirname.'/js/scissors.js' );
    
    		$thisUrl = admin_url('admin-ajax.php');
    		echo "<!-- JS loaded for Scissors in media library -->\n";
    		echo "<script type='text/javascript'>\n/* <![CDATA[ */\n";
    		echo "scissors = {\n";
    		echo "ajaxUrl: '$thisUrl'";
    
    		$intermediate_image_sizes = get_intermediate_image_sizes();
    		foreach ($intermediate_image_sizes as $size) {
    			if ($size=='large' || $size=='medium' || $size=='thumbnail') {
    				// standard WP sizes large, medium, thumbmnail
    				$width = intval(get_option("{$size}_size_w"));
    				$height = intval(get_option("{$size}_size_h"));
    				$aspectRatio = max(1, $width) / max(1, $height);
    				if(!get_option("{$size}_crop")) $aspectRatio = 0;
    
    			} else {
    				if (isset($_wp_additional_image_sizes[$size])) {
    					$width = $_wp_additional_image_sizes[$size]['width'];
    					$height = $_wp_additional_image_sizes[$size]['height'];
    					$aspectRatio = max(1, $width) / max(1, $height);
    					if(!$_wp_additional_image_sizes[$size]['crop']) $aspectRatio = 0;
    				} else {
    					$aspectRatio = 0;
    				}
    			}
    			echo ",\n'{$size}AspectRatio': $aspectRatio";
    		}		
    
    		echo "\n}\n";
    		echo "/* ]]> */\n</script>\n";
    		echo "<!-- End of JS loaded for Scissors in media library -->\n";
    	}
    }

    Just an update on this, Facebook has fixed the bug. Everything should work properly again.

    I have this same problem, but discovered its not a problem with the plugin, but with Facebook itself.

    Read more about it here: Facebook Comments – Require CAPTCHA – Unknown Error

    Anybody else who gets this error, should vote up the bug report on Facebook’s bug tracker.

Viewing 4 replies - 1 through 4 (of 4 total)