Created
October 10, 2012 12:19
-
-
Save reformatco/3865249 to your computer and use it in GitHub Desktop.
Revisions
-
benpalmer79 revised this gist
Oct 10, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ // scissors.php in Scissors Continued // Source: http://wordpress.org/support/topic/plugin-scissors-continued-custom-image-sizes-arent-handled function scissors_admin_head() { -
benpalmer79 created this gist
Oct 10, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,48 @@ // scissors.php in Scissors Continued 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"; } } function scissors_crop($post, $srcfile, $src) { global $_wp_additional_image_sizes;