Plugin Directory

Changeset 159761


Ignore:
Timestamp:
10/01/2009 06:00:07 PM (16 years ago)
Author:
kestrel_id
Message:

Update 0.6.1

Location:
choicecuts-image-juggler/trunk/cc_image_juggler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • choicecuts-image-juggler/trunk/cc_image_juggler/cc_image_juggler.php

    r154620 r159761  
    33Plugin Name: ChoiceCuts Image Juggler
    44Plugin URI: http://www.workwithchoicecuts.com
    5 Version: 0.5.2, 14/9/2009
     5Version: 0.6.1, 30/9/2009
    66Author: http://www.workwithchoicecuts.com
    77Description: 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.
     
    2828Create square thumbnail from passed image_path by proportionally reducing image to specified minimum
    2929
    30 Remove all images from passed string/content
     30Remove all images from passed string/content, optionally apply 'the_content' filter
    3131
    3232Automatically resize any images outside set width values by add_filter on the_content
     
    4141TODO
    4242Resize remote images
    43 Make filters available by template selection
     43Make filters available by template/category
    4444Pass parameter options into Filter functions
    4545Upgrade thumbnail.inc.php to most recent library version, v.3
     46Remove image resizing options from upload window
     47Integrate image captions into lightbox
    4648
    4749*/
     
    5759
    5860// Select your preferred lightbox. 1: jQuery lightbox 2: jQuery pirobox. Any other value >> default = no lightbox
    59 define('LIGHTBOX_CHOICE', 2);
     61define('LIGHTBOX_CHOICE', 0);
    6062
    6163// Max lightbox popup height
     
    6971define('FILTER_FLEXI_WIDTH', FALSE);
    7072
     73// Enable filter on the_content  - all images width resize. N.B. edit variable vaules within the actual funciton to specify exact requirements.
     74define('FILTER_ALL_WIDTH', FALSE);
     75
    7176// Enable filter on the_content  - all images cropped. N.B. edit variable vaules within the actual funciton to specify exact requirements.
    7277define('FILTER_ALL_CROP', FALSE);
    7378
    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
     80define('FILTER_LIGHTBOX', FALSE);
     81
    7682
    7783// Alter this path if you wish to use a different default image
     
    97103define('PLUGIN_PATH', WP_PLUGIN_URL .'/cc_image_juggler/includes/');
    98104define('LIGHTBOX_PATH', WP_PLUGIN_URL .'/cc_image_juggler/includes/lightbox/'.$lbDirectory.'/');
    99 
    100105
    101106
     
    306311    * @return content_noImg: string
    307312    */
    308     function ccImj_noImg($content)
     313    function ccImj_noImg($content, $apply_filter=FALSE)
    309314    {
    310315        $content_noImg = preg_replace("/\<img(.*)\/\>/", "", $content);
     316       
     317        if ( $apply_filter ) {
     318            $content_noImg = apply_filters( 'the_content', $content_noImg );
     319        }
    311320       
    312321        return $content_noImg;
     
    508517    * @return html_partial: string
    509518    */
    510     function ccImj_cropSquareCtr( $img_path, $size=NULL, $extraTags=NULL )
     519    function ccImj_cropSquareCtr( $img_path, $size, $extraTags=NULL )
    511520    {
    512521        $img_dim = NULL;
     
    575584    * @return html_partial: string. send to output or returned as variable depending on @param: return
    576585    */ 
    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 )
    578587    {
    579588        $img_path = ccImj_getFirstImg( $content );
     
    593602    * @param img_path: string - filename path
    594603    * @param width: integer - width dimension
    595     * @param min_height: integer - min. height dimension
     604    * @param min_height: integer - minimum height dimension
    596605    * @param link: boolean/string - lighbox integrate or hyperlink URL
    597606    * @param return: boolean - output conditional
     
    599608    * @return html_partial: string. send to output or returned as variable depending on @param: return
    600609    */
    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        }
    604618        $html_partial = ccImj_addLink( $html_partial, $link, $img_path );
    605619       
     
    612626    * @param img_path: string - filename path
    613627    * @param height: integer - height dimension
    614     * @param width: integer - width dimension
     628    * @param min_width: integer - minimum width dimension
    615629    * @param link: boolean/string - lighbox integrate or hyperlink URL
    616630    * @param return: boolean - output conditional
     
    618632    * @return html_partial: string. send to output or returned as variable depending on @param: return
    619633    */
    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        }
    623642        $html_partial = ccImj_addLink( $html_partial, $link, $img_path );
    624643       
     
    636655    * @return html_partial: string. send to output or returned as variable depending on @param: return
    637656    */
    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 )
    639658    {
    640659        $html_partial = ccImj_cropSquareCtr( $img_path, $size, $extraTags );
     
    657676    function ccImj_flexiWidth( $content )
    658677    {
    659         $link = TRUE;
     678        // TODO: variables I have yet to figure out how to pass into this function from wordpress
     679        $link_path = TRUE;
    660680        $min_width = 240;
    661681        $max_width = 510;
     
    671691                   
    672692                    if ($img_width > $max_width) {
    673                            
    674693                        $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);
    678694                    }
    679695                    elseif ($img_width < $min_width) {
    680                            
    681696                        $html_partial = ccImj_resizeWidth( $image['url'], $min_width );
    682                        
    683                         $content = str_replace($image['tag'], $html_partial, $content);
    684697                    }
     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);
    685706                }
    686707            }
     
    701722    function ccImj_allWidth( $content )
    702723    {
    703         $link = TRUE;
     724        // TODO: variables I have yet to figure out how to pass into this function from wordpress
     725        $link_path = TRUE;
    704726        $width = 500;
    705727       
     
    716738                   
    717739                        $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                        }
    719743                       
    720744                        $content = str_replace($image['tag'], $html_partial, $content);
     
    732756
    733757    /**
    734     * ccImj_allCrop: Resize all images, to specified square thumbnail size,  in every post to specified height and wrap it in a hyperlink if desired
     758    * ccImj_allCrop: Resize all images, to specified square thumbnail size, in every post to specified height and wrap it in a hyperlink if desired
    735759    * @param content: string
    736760    * @return content: string. modified post content
     
    738762    function ccImj_allCrop( $content )
    739763    {
    740         $link = TRUE;
     764        // TODO: variables I have yet to figure out how to pass into this function from wordpress
     765        $link_path = TRUE;
    741766        $size = 500;
    742767       
     
    753778                   
    754779                        $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                        }
    756783                       
    757784                        $content = str_replace($image['tag'], $html_partial, $content);
  • choicecuts-image-juggler/trunk/cc_image_juggler/readme.txt

    r154620 r159761  
    5151== Changelog ==
    5252
     53= 0.6.1 =
     54Add a parameter to ccImj_noImg to offer apply_filter the_content as part of the function
     55Adjust 3rd parameter, Height, on ccImj_linkedLandscape. If passed as NULL image resize width with proportional height, rather than only offering set width/height
     56Adjust 3rd parameter, Width, on ccImj_linkedPortrait. If passed as NULL image resize height with proportional width, rather than only offering set width/height
     57Remove the NULL default from the Size parameter on ccImj_linkedThumb
     58Remove the NULL default from the Size parameter on ccImj_firstThumb
     59Remove the NULL default from the Size parameter on ccImj_cropSquareCtr
     60Add the FILTER_LIGHTBOX constant, so lightbox integration can be controlled seperately for the FILTER FUNCTIONS
     61Alter ccImj_linkedPortrait parameter, width, to min_width
     62Fixed a logic error in ccImj_flexiWidth (thanx Lough)
     63
    5364= 0.5.2 =
    5465Addition of ccImj_flexiWidth function, within FILTER FUNCTION section
    5566Add a $images returned conditional to prevent error within all FILTER FUNCTIONs
    56 Fix bug in ccImj_getAllImg, ['url'] was not being returned properly
     67Fix bug in ccImj_getAllImg, ['url'] was not being returned properly (thanx Stewart)
    5768Amendments made to readme.txt to improve documentation quality
    5869
     
    6475
    6576
    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 UTILITIES
    71    
    72 ccImj_getFirstImg
    73 - extract the first image from passed $content, return image file path only
    74 << php code start >>
    75     $image = ccImj_getFirstImg( $postContent ); ?>
    76 << php code end >>
    77 
    78 ccImj_getAllImg
    79 - 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_noImg
    85 - remove all images from the passed parameter, typically post content
    86 << php code start >>
    87     $contentWithoutImages = ccImj_noImg( $postContent ); ?>
    88 << php code end >>
    89 
    90 
    91 // -------------------------------------------------------------------------- IMAGE MANIPULATION PREPARATION
    92 
    93 ccImj_resizeWidthURL
    94 - resize image to specified width, pass min_height to ensure consistent image dimensions. Return only the image resize URL, without embedding any HTML tags
    95 << php code start >>
    96     $resizeUrl = ccImj_resizeWidthURL( $img_path, 480, 120 ); ?>
    97 << php code end >>
    98 
    99 ccImj_resizeHeightURL
    100 - resize image to specified height. Return only the image resize URL, without embedding any HTML tags
    101 << php code start >>
    102     $resizeUrl = ccImj_resizeHeightURL( $img_path, 300 ); ?>
    103 << php code end >>
    104 
    105 ccImj_resizeWidth
    106 - resize image to specified width. Return full HTML IMG tag for resized image
    107 << 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_resizeHeight
    112 - resize image to specified height. Return full HTML IMG tag for resized image
    113 << php code start >>
    114     $image_html = ccImj_resizeHeight( $img_path, 300, 'class="special-image-style"' ); ?>
    115 << php code end >>
    116 
    117 ccImj_cropLandscape
    118 - proportionally resize image to specified width, then crop excess height as required
    119 << php code start >>
    120     $image_html = ccImj_cropLandscape( $img_path, 300, 240 ); ?>
    121 << php code end >>
    122 
    123 ccImj_cropPortrait
    124 - proportionally resize image to specified height, then crop excess width as required
    125 << 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_cropSquareCtr
    130 - resize image to specified size, then crop a square from the centre
    131 << php code start >>
    132     $image_html = ccImj_cropSquareCtr( $img_path, 60, 'class="special-image-style"' )
    133 << php code end >>
    134    
    135 
    136 // -------------------------------------------------------------------------- 'GET FIRST' FUNCTIONS
    137 
    138 ccImj_firstLandscape
    139 - 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
    140 << php code start >>
    141     ccImj_firstLandscape( $postContent, 480, 120, TRUE, FALSE, 'class="special-image-style"' ); ?>
    142 << php code end >>
    143 
    144 ccImj_firstPortrait
    145 - 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
    146 << php code start >>
    147     ccImj_firstPortrait( $postContent, 600, TRUE, FALSE, 'class="special-image-style"' ); ?>
    148 << php code end >>
    149 
    150 ccImj_firstThumb
    151 - extract the first image from the passed content, then crop a square from the centre and wrap it in a hyperlink if desired
    152 << 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 FUNCTIONS
    158 
    159 ccImj_linkedLandscape
    160 - resize image to specified width and height, then wrap it in a hyperlink if desired
    161 << php code start >>
    162     ccImj_linkedLandscape( $img_path, 600, 200, FALSE, FALSE, 'class="mega-banner"' ); ?>
    163 << php code end >>
    164 
    165 ccImj_linkedPortrait
    166 - resize image to specified height and width, then wrap it in a hyperlink if desired
    167 << 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_linkedThumb
    172 - resize image to specified size, then crop a square from the centre and wrap it in a hyperlink if desired
    173 << 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 FUNCTIONS
    179 
    180 ccImj_flexiWidth
    181 - 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_allWidth
    185 - resize all images, to specified width, and wrap it in a hyperlink if desired
    186 ** 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_allCrop
    189 - resize all images, to specified square thumbnail size,  in every post to specified height and wrap it in a hyperlink if desired
    190 ** To use this function edit the constant 'FILTER_ALL_CROP' value to be TRUE. Find this at the top of the plugin code.
    19177
    19278
     
    218104<< php code end >>
    219105
     106
     107== Full Plugin API ==
     108
     109N.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   
     113ccImj_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
     119ccImj_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
     125ccImj_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
     134ccImj_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
     140ccImj_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
     146ccImj_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
     152ccImj_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
     158ccImj_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
     164ccImj_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
     170ccImj_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
     179ccImj_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
     185ccImj_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
     191ccImj_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
     200ccImj_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
     206ccImj_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
     212ccImj_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
     221ccImj_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
     225ccImj_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
     229ccImj_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.