Changeset 159761
- Timestamp:
- 10/01/2009 06:00:07 PM (16 years ago)
- Location:
- choicecuts-image-juggler/trunk/cc_image_juggler
- Files:
-
- 2 edited
-
cc_image_juggler.php (modified) (21 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
choicecuts-image-juggler/trunk/cc_image_juggler/cc_image_juggler.php
r154620 r159761 3 3 Plugin Name: ChoiceCuts Image Juggler 4 4 Plugin URI: http://www.workwithchoicecuts.com 5 Version: 0. 5.2, 14/9/20095 Version: 0.6.1, 30/9/2009 6 6 Author: http://www.workwithchoicecuts.com 7 7 Description: ChoiceCuts Image Juggler makes all image handling a piece of cake. Stripping images, resizing to Landscape, resizing to Portrait and creating Thumbnails are all handled. There is also a couple of lightboxes integrated so as to present your images in their original glory. This is all made possible through the use of the Thumbnail.inc.php library, which can be found at http://trac.gxdlabs.com/projects/phpthumb/wiki/Legacy. … … 28 28 Create square thumbnail from passed image_path by proportionally reducing image to specified minimum 29 29 30 Remove all images from passed string/content 30 Remove all images from passed string/content, optionally apply 'the_content' filter 31 31 32 32 Automatically resize any images outside set width values by add_filter on the_content … … 41 41 TODO 42 42 Resize remote images 43 Make filters available by template selection43 Make filters available by template/category 44 44 Pass parameter options into Filter functions 45 45 Upgrade thumbnail.inc.php to most recent library version, v.3 46 Remove image resizing options from upload window 47 Integrate image captions into lightbox 46 48 47 49 */ … … 57 59 58 60 // Select your preferred lightbox. 1: jQuery lightbox 2: jQuery pirobox. Any other value >> default = no lightbox 59 define('LIGHTBOX_CHOICE', 2);61 define('LIGHTBOX_CHOICE', 0); 60 62 61 63 // Max lightbox popup height … … 69 71 define('FILTER_FLEXI_WIDTH', FALSE); 70 72 73 // Enable filter on the_content - all images width resize. N.B. edit variable vaules within the actual funciton to specify exact requirements. 74 define('FILTER_ALL_WIDTH', FALSE); 75 71 76 // Enable filter on the_content - all images cropped. N.B. edit variable vaules within the actual funciton to specify exact requirements. 72 77 define('FILTER_ALL_CROP', FALSE); 73 78 74 // Enable filter on the_content - all images width resize. N.B. edit variable vaules within the actual funciton to specify exact requirements. 75 define('FILTER_ALL_WIDTH', FALSE); 79 // Enable lightbox integration for all images resized by a FILTER FUNCTION 80 define('FILTER_LIGHTBOX', FALSE); 81 76 82 77 83 // Alter this path if you wish to use a different default image … … 97 103 define('PLUGIN_PATH', WP_PLUGIN_URL .'/cc_image_juggler/includes/'); 98 104 define('LIGHTBOX_PATH', WP_PLUGIN_URL .'/cc_image_juggler/includes/lightbox/'.$lbDirectory.'/'); 99 100 105 101 106 … … 306 311 * @return content_noImg: string 307 312 */ 308 function ccImj_noImg($content )313 function ccImj_noImg($content, $apply_filter=FALSE) 309 314 { 310 315 $content_noImg = preg_replace("/\<img(.*)\/\>/", "", $content); 316 317 if ( $apply_filter ) { 318 $content_noImg = apply_filters( 'the_content', $content_noImg ); 319 } 311 320 312 321 return $content_noImg; … … 508 517 * @return html_partial: string 509 518 */ 510 function ccImj_cropSquareCtr( $img_path, $size =NULL, $extraTags=NULL )519 function ccImj_cropSquareCtr( $img_path, $size, $extraTags=NULL ) 511 520 { 512 521 $img_dim = NULL; … … 575 584 * @return html_partial: string. send to output or returned as variable depending on @param: return 576 585 */ 577 function ccImj_firstThumb( $content, $size =NULL, $link=FALSE, $return=FALSE, $extraTags=NULL )586 function ccImj_firstThumb( $content, $size, $link=FALSE, $return=FALSE, $extraTags=NULL ) 578 587 { 579 588 $img_path = ccImj_getFirstImg( $content ); … … 593 602 * @param img_path: string - filename path 594 603 * @param width: integer - width dimension 595 * @param min_height: integer - min .height dimension604 * @param min_height: integer - minimum height dimension 596 605 * @param link: boolean/string - lighbox integrate or hyperlink URL 597 606 * @param return: boolean - output conditional … … 599 608 * @return html_partial: string. send to output or returned as variable depending on @param: return 600 609 */ 601 function ccImj_linkedLandscape( $img_path, $width, $min_height, $link=FALSE, $return=FALSE, $extraTags=NULL ) 602 { 603 $html_partial = ccImj_cropLandscape( $img_path, $width, $min_height, $extraTags ); 610 function ccImj_linkedLandscape( $img_path, $width, $min_height=NULL, $link=FALSE, $return=FALSE, $extraTags=NULL ) 611 { 612 if ( $min_height != NULL ) { 613 $html_partial = ccImj_cropLandscape( $img_path, $width, $min_height, $extraTags ); 614 } 615 else { 616 $html_partial = ccImj_resizeWidth( $img_path, $width, $extraTags ); 617 } 604 618 $html_partial = ccImj_addLink( $html_partial, $link, $img_path ); 605 619 … … 612 626 * @param img_path: string - filename path 613 627 * @param height: integer - height dimension 614 * @param width: integer -width dimension628 * @param min_width: integer - minimum width dimension 615 629 * @param link: boolean/string - lighbox integrate or hyperlink URL 616 630 * @param return: boolean - output conditional … … 618 632 * @return html_partial: string. send to output or returned as variable depending on @param: return 619 633 */ 620 function ccImj_linkedPortrait( $img_path, $height, $width, $link=FALSE, $return=FALSE, $extraTags=NULL ) 621 { 622 $html_partial = ccImj_cropPortrait( $img_path, $height, $width, $extraTags ); 634 function ccImj_linkedPortrait( $img_path, $height, $min_width=NULL, $link=FALSE, $return=FALSE, $extraTags=NULL ) 635 { 636 if ( $min_width != NULL ) { 637 $html_partial = ccImj_cropPortrait( $img_path, $height, $min_width, $extraTags ); 638 } 639 else { 640 $html_partial = ccImj_resizeHeight( $img_path, $height, $extraTags ); 641 } 623 642 $html_partial = ccImj_addLink( $html_partial, $link, $img_path ); 624 643 … … 636 655 * @return html_partial: string. send to output or returned as variable depending on @param: return 637 656 */ 638 function ccImj_linkedThumb( $img_path, $size =NULL, $link=FALSE, $return=FALSE, $extraTags=NULL )657 function ccImj_linkedThumb( $img_path, $size, $link=FALSE, $return=FALSE, $extraTags=NULL ) 639 658 { 640 659 $html_partial = ccImj_cropSquareCtr( $img_path, $size, $extraTags ); … … 657 676 function ccImj_flexiWidth( $content ) 658 677 { 659 $link = TRUE; 678 // TODO: variables I have yet to figure out how to pass into this function from wordpress 679 $link_path = TRUE; 660 680 $min_width = 240; 661 681 $max_width = 510; … … 671 691 672 692 if ($img_width > $max_width) { 673 674 693 $html_partial = ccImj_resizeWidth( $image['url'], $max_width ); 675 $html_partial = ccImj_addLink( $html_partial, $link, $image['url'] );676 677 $content = str_replace($image['tag'], $html_partial, $content);678 694 } 679 695 elseif ($img_width < $min_width) { 680 681 696 $html_partial = ccImj_resizeWidth( $image['url'], $min_width ); 682 683 $content = str_replace($image['tag'], $html_partial, $content);684 697 } 698 else { 699 $html_partial = $image['tag']; 700 } 701 702 if (FILTER_LIGHTBOX) { 703 $html_partial = ccImj_addLink( $html_partial, $link_path, $image['url'] ); 704 } 705 $content = str_replace($image['tag'], $html_partial, $content); 685 706 } 686 707 } … … 701 722 function ccImj_allWidth( $content ) 702 723 { 703 $link = TRUE; 724 // TODO: variables I have yet to figure out how to pass into this function from wordpress 725 $link_path = TRUE; 704 726 $width = 500; 705 727 … … 716 738 717 739 $html_partial = ccImj_resizeWidth( $image['url'], $width ); 718 $html_partial = ccImj_addLink( $html_partial, $link, $image['url'] ); 740 if (FILTER_LIGHTBOX) { 741 $html_partial = ccImj_addLink( $html_partial, $link_path, $image['url'] ); 742 } 719 743 720 744 $content = str_replace($image['tag'], $html_partial, $content); … … 732 756 733 757 /** 734 * ccImj_allCrop: Resize all images, to specified square thumbnail size, in every post to specified height and wrap it in a hyperlink if desired758 * ccImj_allCrop: Resize all images, to specified square thumbnail size, in every post to specified height and wrap it in a hyperlink if desired 735 759 * @param content: string 736 760 * @return content: string. modified post content … … 738 762 function ccImj_allCrop( $content ) 739 763 { 740 $link = TRUE; 764 // TODO: variables I have yet to figure out how to pass into this function from wordpress 765 $link_path = TRUE; 741 766 $size = 500; 742 767 … … 753 778 754 779 $html_partial = ccImj_cropSquareCtr( $image['url'], $size ); 755 $html_partial = ccImj_addLink( $html_partial, $link, $image['url'] ); 780 if (FILTER_LIGHTBOX) { 781 $html_partial = ccImj_addLink( $html_partial, $link_path, $image['url'] ); 782 } 756 783 757 784 $content = str_replace($image['tag'], $html_partial, $content); -
choicecuts-image-juggler/trunk/cc_image_juggler/readme.txt
r154620 r159761 51 51 == Changelog == 52 52 53 = 0.6.1 = 54 Add a parameter to ccImj_noImg to offer apply_filter the_content as part of the function 55 Adjust 3rd parameter, Height, on ccImj_linkedLandscape. If passed as NULL image resize width with proportional height, rather than only offering set width/height 56 Adjust 3rd parameter, Width, on ccImj_linkedPortrait. If passed as NULL image resize height with proportional width, rather than only offering set width/height 57 Remove the NULL default from the Size parameter on ccImj_linkedThumb 58 Remove the NULL default from the Size parameter on ccImj_firstThumb 59 Remove the NULL default from the Size parameter on ccImj_cropSquareCtr 60 Add the FILTER_LIGHTBOX constant, so lightbox integration can be controlled seperately for the FILTER FUNCTIONS 61 Alter ccImj_linkedPortrait parameter, width, to min_width 62 Fixed a logic error in ccImj_flexiWidth (thanx Lough) 63 53 64 = 0.5.2 = 54 65 Addition of ccImj_flexiWidth function, within FILTER FUNCTION section 55 66 Add a $images returned conditional to prevent error within all FILTER FUNCTIONs 56 Fix bug in ccImj_getAllImg, ['url'] was not being returned properly 67 Fix bug in ccImj_getAllImg, ['url'] was not being returned properly (thanx Stewart) 57 68 Amendments made to readme.txt to improve documentation quality 58 69 … … 64 75 65 76 66 == Full Plugin API ==67 68 N.B. All functions are technical documented within the plugin code. Read through file cc_image_juggler.php within the plugin install folder for more information.69 70 // -------------------------------------------------------------------------- IMAGE EXRACTION UTILITIES71 72 ccImj_getFirstImg73 - extract the first image from passed $content, return image file path only74 << php code start >>75 $image = ccImj_getFirstImg( $postContent ); ?>76 << php code end >>77 78 ccImj_getAllImg79 - extract all images from passed $content, returns a multi-dimensional array. The returned array contains an element for each image found. Within each element is an associative array as follows: ['tag'] - full html img tag. ['url'] - image file path only.80 << php code start >>81 $images = ccImj_getAllImg( $postContent ); ?>82 << php code end >>83 84 ccImj_noImg85 - remove all images from the passed parameter, typically post content86 << php code start >>87 $contentWithoutImages = ccImj_noImg( $postContent ); ?>88 << php code end >>89 90 91 // -------------------------------------------------------------------------- IMAGE MANIPULATION PREPARATION92 93 ccImj_resizeWidthURL94 - resize image to specified width, pass min_height to ensure consistent image dimensions. Return only the image resize URL, without embedding any HTML tags95 << php code start >>96 $resizeUrl = ccImj_resizeWidthURL( $img_path, 480, 120 ); ?>97 << php code end >>98 99 ccImj_resizeHeightURL100 - resize image to specified height. Return only the image resize URL, without embedding any HTML tags101 << php code start >>102 $resizeUrl = ccImj_resizeHeightURL( $img_path, 300 ); ?>103 << php code end >>104 105 ccImj_resizeWidth106 - resize image to specified width. Return full HTML IMG tag for resized image107 << php code start >>108 $image_html = ccImj_resizeWidth( $img_path, 480, 'class="special-image-style" rel="ajax-link-code-13"' ); ?>109 << php code end >>110 111 ccImj_resizeHeight112 - resize image to specified height. Return full HTML IMG tag for resized image113 << php code start >>114 $image_html = ccImj_resizeHeight( $img_path, 300, 'class="special-image-style"' ); ?>115 << php code end >>116 117 ccImj_cropLandscape118 - proportionally resize image to specified width, then crop excess height as required119 << php code start >>120 $image_html = ccImj_cropLandscape( $img_path, 300, 240 ); ?>121 << php code end >>122 123 ccImj_cropPortrait124 - proportionally resize image to specified height, then crop excess width as required125 << php code start >>126 $image_html = ccImj_cropPortrait( $img_path, 300, 240, 'class="special-image-style" alt="Your Blog"' ); ?>127 << php code end >>128 129 ccImj_cropSquareCtr130 - resize image to specified size, then crop a square from the centre131 << php code start >>132 $image_html = ccImj_cropSquareCtr( $img_path, 60, 'class="special-image-style"' )133 << php code end >>134 135 136 // -------------------------------------------------------------------------- 'GET FIRST' FUNCTIONS137 138 ccImj_firstLandscape139 - extract the first image from the passed content, resize image to specified width, crop the excess if required and wrap it in a hyperlink if desired140 << php code start >>141 ccImj_firstLandscape( $postContent, 480, 120, TRUE, FALSE, 'class="special-image-style"' ); ?>142 << php code end >>143 144 ccImj_firstPortrait145 - extract the first image from the passed content, resize image to specified height, crop the excess if required and wrap it in a hyperlink if desired146 << php code start >>147 ccImj_firstPortrait( $postContent, 600, TRUE, FALSE, 'class="special-image-style"' ); ?>148 << php code end >>149 150 ccImj_firstThumb151 - extract the first image from the passed content, then crop a square from the centre and wrap it in a hyperlink if desired152 << php code start >>153 $image_html = ccImj_firstThumb( $content, 130, FALSE, TRUE, 'class="thumbnail-image-style"' ); ?>154 << php code end >>155 156 157 // -------------------------------------------------------------------------- RESIZE & CROP PASSED IMAGE FUNCTIONS158 159 ccImj_linkedLandscape160 - resize image to specified width and height, then wrap it in a hyperlink if desired161 << php code start >>162 ccImj_linkedLandscape( $img_path, 600, 200, FALSE, FALSE, 'class="mega-banner"' ); ?>163 << php code end >>164 165 ccImj_linkedPortrait166 - resize image to specified height and width, then wrap it in a hyperlink if desired167 << php code start >>168 $your_variable = ccImj_linkedPortrait( $img_path, 400, 180, TRUE, TRUE, 'class="thumbnail-image-style"' ); ?>169 << php code end >>170 171 ccImj_linkedThumb172 - resize image to specified size, then crop a square from the centre and wrap it in a hyperlink if desired173 << php code start >>174 ccImj_linkedThumb( $img_path, 200, 'http://www.workwithchoicecuts.com', FALSE, 'class="thumbnail-image-style"' )175 << php code end >>176 177 178 // -------------------------------------------------------------------------- FILTER ALL FUNCTIONS179 180 ccImj_flexiWidth181 - resize all images, to be within specified width sizes, in every post. if image is larger than max_width resize and present original via lightbox, or if smaller than min_width resize up to min_width.182 ** To use this function edit the constant 'FILTER_FLEXI_WIDTH' value to be TRUE. Find this at the top of the plugin code.183 184 ccImj_allWidth185 - resize all images, to specified width, and wrap it in a hyperlink if desired186 ** To use this function edit the constant 'FILTER_ALL_WIDTH' value to be TRUE. Find this at the top of the plugin code.187 188 ccImj_allCrop189 - resize all images, to specified square thumbnail size, in every post to specified height and wrap it in a hyperlink if desired190 ** To use this function edit the constant 'FILTER_ALL_CROP' value to be TRUE. Find this at the top of the plugin code.191 77 192 78 … … 218 104 << php code end >> 219 105 106 107 == Full Plugin API == 108 109 N.B. All functions are technical documented within the plugin code. Read through file cc_image_juggler.php within the plugin install folder for more information. 110 111 // -------------------------------------------------------------------------- IMAGE EXRACTION UTILITIES 112 113 ccImj_getFirstImg 114 - extract the first image from passed $content, return image file path only 115 << php code start >> 116 $image = ccImj_getFirstImg( $postContent ); ?> 117 << php code end >> 118 119 ccImj_getAllImg 120 - extract all images from passed $content, returns a multi-dimensional array. The returned array contains an element for each image found. Within each element is an associative array as follows: ['tag'] - full html img tag. ['url'] - image file path only. 121 << php code start >> 122 $images = ccImj_getAllImg( $postContent ); ?> 123 << php code end >> 124 125 ccImj_noImg 126 - remove all images from the passed parameter, typically post content 127 << php code start >> 128 $contentWithoutImages = ccImj_noImg( $postContent ); ?> 129 << php code end >> 130 131 132 // -------------------------------------------------------------------------- IMAGE MANIPULATION PREPARATION 133 134 ccImj_resizeWidthURL 135 - resize image to specified width, pass min_height to ensure consistent image dimensions. Return only the image resize URL, without embedding any HTML tags 136 << php code start >> 137 $resizeUrl = ccImj_resizeWidthURL( $img_path, 480, 120 ); ?> 138 << php code end >> 139 140 ccImj_resizeHeightURL 141 - resize image to specified height. Return only the image resize URL, without embedding any HTML tags 142 << php code start >> 143 $resizeUrl = ccImj_resizeHeightURL( $img_path, 300 ); ?> 144 << php code end >> 145 146 ccImj_resizeWidth 147 - resize image to specified width. Return full HTML IMG tag for resized image 148 << php code start >> 149 $image_html = ccImj_resizeWidth( $img_path, 480, 'class="special-image-style" rel="ajax-link-code-13"' ); ?> 150 << php code end >> 151 152 ccImj_resizeHeight 153 - resize image to specified height. Return full HTML IMG tag for resized image 154 << php code start >> 155 $image_html = ccImj_resizeHeight( $img_path, 300, 'class="special-image-style"' ); ?> 156 << php code end >> 157 158 ccImj_cropLandscape 159 - proportionally resize image to specified width, then crop excess height as required 160 << php code start >> 161 $image_html = ccImj_cropLandscape( $img_path, 300, 240 ); ?> 162 << php code end >> 163 164 ccImj_cropPortrait 165 - proportionally resize image to specified height, then crop excess width as required 166 << php code start >> 167 $image_html = ccImj_cropPortrait( $img_path, 300, 240, 'class="special-image-style" alt="Your Blog"' ); ?> 168 << php code end >> 169 170 ccImj_cropSquareCtr 171 - resize image to specified size, then crop a square from the centre 172 << php code start >> 173 $image_html = ccImj_cropSquareCtr( $img_path, 60, 'class="special-image-style"' ) 174 << php code end >> 175 176 177 // -------------------------------------------------------------------------- 'GET FIRST' FUNCTIONS 178 179 ccImj_firstLandscape 180 - extract the first image from the passed content, resize image to specified width, crop the excess if required and wrap it in a hyperlink if desired 181 << php code start >> 182 ccImj_firstLandscape( $postContent, 480, TRUE, FALSE, 'class="special-image-style"' ); ?> 183 << php code end >> 184 185 ccImj_firstPortrait 186 - extract the first image from the passed content, resize image to specified height, crop the excess if required and wrap it in a hyperlink if desired 187 << php code start >> 188 ccImj_firstPortrait( $postContent, 600, TRUE, FALSE, 'class="special-image-style"' ); ?> 189 << php code end >> 190 191 ccImj_firstThumb 192 - extract the first image from the passed content, then crop a square from the centre and wrap it in a hyperlink if desired 193 << php code start >> 194 $image_html = ccImj_firstThumb( $content, 130, FALSE, TRUE, 'class="thumbnail-image-style"' ); ?> 195 << php code end >> 196 197 198 // -------------------------------------------------------------------------- RESIZE & CROP PASSED IMAGE FUNCTIONS 199 200 ccImj_linkedLandscape 201 - resize image to specified width and height, then wrap it in a hyperlink if desired 202 << php code start >> 203 ccImj_linkedLandscape( $img_path, 600, 200, FALSE, FALSE, 'class="mega-banner"' ); ?> 204 << php code end >> 205 206 ccImj_linkedPortrait 207 - resize image to specified height and width, then wrap it in a hyperlink if desired 208 << php code start >> 209 $your_variable = ccImj_linkedPortrait( $img_path, 400, 180, TRUE, TRUE, 'class="thumbnail-image-style"' ); ?> 210 << php code end >> 211 212 ccImj_linkedThumb 213 - resize image to specified size, then crop a square from the centre and wrap it in a hyperlink if desired 214 << php code start >> 215 ccImj_linkedThumb( $img_path, 200, 'http://www.workwithchoicecuts.com', FALSE, 'class="thumbnail-image-style"' ) 216 << php code end >> 217 218 219 // -------------------------------------------------------------------------- FILTER ALL FUNCTIONS 220 221 ccImj_flexiWidth 222 - resize all images, to be within specified width sizes, in every post. if image is larger than max_width resize and present original via lightbox, or if smaller than min_width resize up to min_width. 223 ** To use this function edit the constant 'FILTER_FLEXI_WIDTH' value to be TRUE. Find this at the top of the plugin code. 224 225 ccImj_allWidth 226 - resize all images, to specified width, and wrap it in a hyperlink if desired 227 ** To use this function edit the constant 'FILTER_ALL_WIDTH' value to be TRUE. Find this at the top of the plugin code. 228 229 ccImj_allCrop 230 - resize all images, to specified square thumbnail size, in every post to specified height and wrap it in a hyperlink if desired 231 ** To use this function edit the constant 'FILTER_ALL_CROP' value to be TRUE. Find this at the top of the plugin code. 232 233
Note: See TracChangeset
for help on using the changeset viewer.