Changeset 779794
- Timestamp:
- 09/29/2013 08:54:40 AM (13 years ago)
- Location:
- amtythumb
- Files:
-
- 11 added
- 6 edited
-
tags/4.0.0 (added)
-
tags/4.0.0/amtyThumb.php (added)
-
tags/4.0.0/amtyThumbAdminFunction.php (added)
-
tags/4.0.0/amtyThumbAdminPg.php (added)
-
tags/4.0.0/amtytextthumb.gif (added)
-
tags/4.0.0/cacheFunction.php (added)
-
tags/4.0.0/invalid.gif (added)
-
tags/4.0.0/lead-img.php (added)
-
tags/4.0.0/readme.txt (added)
-
tags/4.0.0/supportingFunction.php (added)
-
tags/4.0.0/videothumb.php (added)
-
trunk/amtyThumb.php (modified) (1 diff)
-
trunk/amtyThumbAdminFunction.php (modified) (2 diffs)
-
trunk/amtyThumbAdminPg.php (modified) (4 diffs)
-
trunk/cacheFunction.php (modified) (6 diffs)
-
trunk/lead-img.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
amtythumb/trunk/amtyThumb.php
r777391 r779794 6 6 7 7 Author: Amit Gupta 8 Version: 3.2.08 Version: 4.0.0 9 9 Author URI: http://article-stack.com/ 10 10 */ -
amtythumb/trunk/amtyThumbAdminFunction.php
r776329 r779794 9 9 echo '</div>'; 10 10 echo '<div style="float:left;width:50%;">'; 11 $dir = WP_PLUGIN_DIR . "/amtythumb/cache";12 $url = WP_PLUGIN_URL . "/amtythumb/cache";11 $dir = getAmtyThumbCachePath(); 12 $url = getAmtyThumbCacheURL(); 13 13 echo "<br />Image path on server : " . $dir; 14 14 echo "<br />Image url : " . $url; … … 36 36 } 37 37 //echo $img; 38 $img_uri = WP_PLUGIN_DIR . "/amtythumb/testimage.jpg";39 $img_url = WP_PLUGIN_URL . "/amtythumb/testimage.jpg";38 $img_uri = getAmtyThumbPluginPath() . "testimage.jpg"; 39 $img_url = getAmtyThumbPluginURL() . "testimage.jpg"; 40 40 //echo $img_uri; 41 41 $starttime = time(); -
amtythumb/trunk/amtyThumbAdminPg.php
r776474 r779794 54 54 <br /> 55 55 <br /> 56 Total images cached : <?php echo amty_getImageCacheCount(); ?> 56 Total images cached : <?php echo amty_getImageCacheCount(); ?> <br/> 57 Total thumbnails in cache : <?php echo amty_getFilesInCacheFolder(); ?> 57 58 <p class="submit"> 58 59 <input type="submit" name="Submit" value="submit" /> … … 61 62 </div> 62 63 <hr /> 64 63 65 <div> 64 <strong>Test Image cache</strong> 66 <h1> Manual Caching </h1> 67 <form name="amtyThumb_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> 68 <input type="hidden" name="manualcache" value="Y" /> 69 <p> 70 Cache For : 71 <select name="action"> 72 <option value="0">Single Post</option> 73 <option value="1">All posts</option> 74 </select> 75 Post ID (optional) : <input type="text" name="post_id" /> 76 Width : <input type="text" name="width" /> 77 , height : <input type="text" name="height" /> 78 , Constrain : <select name="constrain"> 79 <option value="0">0</option> 80 <option value="1">1</option> 81 </select> 82 , Zoom/Crop : <select name="zc"> 83 <option value="0">Zoom</option> 84 <option value="1">Crop</option> 85 </select> 86 <input type="submit" name="Submit" value="submit" /> 87 </p> 88 <?php 89 if(isset($_POST['manualcache']) && $_POST['manualcache'] == 'Y') { 90 if(isset($_POST['width']) && isset($_POST['height']) && isset($_POST['constrain']) && isset($_POST['zc'])) { 91 if($_POST['action'] == '0') { 92 if(isset($_POST['post_id'])) { 93 amty_populateCacheManual($_POST['width'],$_POST['height'],$_POST['constrain'],$_POST['zc'],$_POST['post_id']); 94 }else{ 95 echo "Please provide Post ID."; 96 } 97 }else{ 98 amty_populateCacheAllManual($_POST['width'],$_POST['height'],$_POST['constrain'],$_POST['zc']); 99 } 100 }else{ 101 echo "Please provide all required parameters."; 102 } 103 } 104 ?> 105 </form> 106 </div> 107 <hr /> 108 <div> 109 <h1>Test Image cache</h1> 65 110 <form name="amtyThumbShow_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> 66 111 <input type="hidden" name="showthumb" value="Y" /> … … 77 122 <hr /> 78 123 <div> 79 <strong>Test Plugin </strong> 80 <br /> 81 <div style="float:left"> 82 <form name="amtyThumbTest_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> 83 <input type="hidden" name="testplugin" value="Y" /> 84 Mode : <select name="mode"><option value="0">Image URL </option><option value="1">Post Id </option></select> 85 Image URL/Post ID : <input type="text" name="post_id" value="<?php echo $_POST['post_id'];?>" style="width:250px"/> 86 <br /> 87 If you don't specify percent then specify width and height both. 88 <br /> 89 Percent (only numeric) : <input type="text" name="percent" value="<?php echo $_POST['percent'];?>" style="width:50px"/> | 90 Width : <input type="text" name="width" value="<?php echo $_POST['width'];?>" style="width:50px"/> 91 Height : <input type="text" name="height" value="<?php echo $_POST['height'];?>" style="width:50px"/> 92 <br /> 93 if you specify Constrain as 0, resized image will be stretched. To maintain the ratio keep it 1. 94 <br /> 95 Zoom/Crop : <select name="zc"><option value="0">0</option><option value="1">1</option></select> 96 Constrain : <select name="cons"><option value="0">0</option><option value="1">1</option></select> 97 <center><p><input type="submit" name="Submit" value="submit" /></p></center> 98 </form> 124 <h1>Test Plugin </h1> 125 126 <form name="amtyThumbTest_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> 127 <input type="hidden" name="testplugin" value="Y" /> 128 Mode : <select name="mode"><option value="0">Image URL </option><option value="1">Post Id </option></select> 129 Image URL/Post ID : <input type="text" name="post_id" value="<?php echo $_POST['post_id'];?>" style="width:250px"/> 130 <br /> 131 If you don't specify percent then specify width and height both. 132 <br /> 133 Percent (only numeric) : <input type="text" name="percent" value="<?php echo $_POST['percent'];?>" style="width:50px"/> | 134 Width : <input type="text" name="width" value="<?php echo $_POST['width'];?>" style="width:50px"/> 135 Height : <input type="text" name="height" value="<?php echo $_POST['height'];?>" style="width:50px"/> 136 <br /> 137 if you specify Constrain as 0, resized image will be stretched. To maintain the ratio keep it 1. 138 <br /> 139 Zoom/Crop : <select name="zc"><option value="0">0</option><option value="1">1</option></select> 140 Constrain : <select name="cons"><option value="0">0</option><option value="1">1</option></select> 141 <center><p><input type="submit" name="Submit" value="submit" /></p></center> 142 143 <?php 144 if($_POST['testplugin'] == 'Y') { 145 if($_POST['mode'] == 0){ 146 amty_testPlugin($_POST['post_id'],'',$_POST['width'],$_POST['height'],$_POST['percent'],$_POST['cons'],$_POST['zc']); 147 } 148 else{ 149 amty_testPlugin('',$_POST['post_id'],$_POST['width'],$_POST['height'],$_POST['percent'],$_POST['cons'],$_POST['zc']); 150 } 151 } 152 ?> 153 </form> 99 154 </div> 155 <hr /> 100 156 <div> 101 <?php 102 if($_POST['testplugin'] == 'Y') { 103 if($_POST['mode'] == 0){ 104 amty_testPlugin($_POST['post_id'],'',$_POST['width'],$_POST['height'],$_POST['percent'],$_POST['cons'],$_POST['zc']); 105 } 106 else{ 107 amty_testPlugin('',$_POST['post_id'],$_POST['width'],$_POST['height'],$_POST['percent'],$_POST['cons'],$_POST['zc']); 108 } 109 } 110 ?> 111 </div> 112 </div> 113 <div style="clear:both;"></div> 114 <hr /> 115 <br /> 157 <h1>Report Broken but cached Links</h1> 116 158 <form name="amtyThumbReport_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> 117 159 <input type="hidden" name="reportBroken" value="Y" /> 118 160 <center><p><input type="submit" name="reportBrokenSubmit" value="Report Broken Cached Images" /></p></center> 119 </form>120 </div>121 <div>122 161 <?php 123 162 if($_POST['reportBroken'] == 'Y') { … … 125 164 } 126 165 ?> 166 </form> 127 167 </div> 128 168 129 <div style="clear:both;"></div>130 169 <hr /> 131 </div> -
amtythumb/trunk/cacheFunction.php
r776588 r779794 1 1 <?php 2 3 function getAmtyThumbCachePath(){ 4 $dir = WP_CONTENT_DIR . "/amtythumbcache/"; 5 if (!file_exists($dir)) { 6 mkdir($dir, 0755, true); 7 } 8 return $dir; 9 } 10 11 function getAmtyThumbPluginURL(){ 12 return WP_PLUGIN_URL . "/amtythumb/"; 13 } 14 15 function getAmtyThumbPluginPath(){ 16 return WP_PLUGIN_DIR . "/amtythumb/"; 17 } 18 19 function getAmtyThumbCacheURL(){ 20 $dir = WP_CONTENT_URL . "/amtythumbcache/"; 21 } 2 22 3 23 //empty image cache and all thumbnails from file system … … 11 31 12 32 function amty_clearImageCacheHard(){ 13 $dir = WP_PLUGIN_DIR . "/amtythumb/cache"; 14 if($handle=opendir($dir)){ 33 if($handle=opendir(getAmtyThumbCachePath())){ 15 34 while ( ($file = readdir($handle)) !==false) { 16 @unlink( $dir.'/'.$file);35 @unlink(getAmtyThumbCachePath().$file); 17 36 } 18 37 closedir($handle); … … 29 48 function amty_deletePostFromCache($postId){ 30 49 if(get_post_meta($postId,'amtyThumb',true) != '' ){ 31 $dir = WP_PLUGIN_DIR . "/amtythumb/cache"; 32 if($handle=opendir($dir)){ 50 if($handle=opendir(getAmtyThumbCachePath())){ 33 51 while ( ($file = readdir($handle)) !==false) { 34 52 if(preg_match('/^'. $postId .'_.*\.jpg/', $file)){ 35 @unlink( $dir.'/'.$file);53 @unlink(getAmtyThumbCachePath().$file); 36 54 } 37 55 } … … 54 72 } 55 73 else{ 56 $img = WP_PLUGIN_URL . "/amtythumb/amtytextthumb.gif";74 $img = getAmtyThumbPluginURL(). "amtytextthumb.gif"; 57 75 } 58 76 }elseif(!isImage($img)){//image is not valid 59 $img = WP_PLUGIN_URL . "/amtythumb/invalid.gif";77 $img = getAmtyThumbPluginURL(). "invalid.gif"; 60 78 } 61 79 update_post_meta($postId,'amtyThumb',$img); … … 70 88 endwhile; 71 89 wp_reset_postdata(); 90 } 91 92 function amty_populateCacheAllManual($w,$h,$c,$zc){ 93 $query = new WP_Query( 'posts_per_page=-1' ); 94 print "caching for : "; 95 while ( $query->have_posts() ) : $query->the_post(); 96 print $pid .","; 97 $pid = get_the_ID(); 98 amty_lead_img($w,$h,$c,'','',$zc,$pid,'',''); 99 endwhile; 100 wp_reset_postdata(); 101 } 102 103 function amty_populateCacheManual($w,$h,$c,$zc,$pid){ 104 amty_lead_img($w,$h,$c,'','',$zc,$pid,'',''); 72 105 } 73 106 … … 90 123 } 91 124 125 function amty_getFilesInCacheFolder(){ 126 $count = 0; 127 $dir = getAmtyThumbCachePath(); 128 if ($handle = opendir($dir)) { 129 while (($file = readdir($handle)) !== false){ 130 if (!in_array($file, array('.', '..')) && !is_dir($dir.$file)) 131 $count++; 132 } 133 } 134 return $count; 135 } 136 92 137 function reportBrokenImage(){ 93 138 $query = new WP_Query( 'posts_per_page=-1' ); -
amtythumb/trunk/lead-img.php
r777391 r779794 27 27 }else{ 28 28 if(isImage($img)){//to avoid invalid path or 404 errors 29 $img = WP_PLUGIN_URL . "/amtythumb/invalid.gif";29 $img = getAmtyThumbPluginURL() . "invalid.gif"; 30 30 } 31 31 } 32 32 33 33 //To save image on disk 34 $img_uri = WP_PLUGIN_DIR . "/amtythumb/cache/". $pid . "_" . $w . "_" . $h . ".jpg";34 $img_uri = getAmtyThumbCachePath() . $pid . "_" . $w . "_" . $h . ".jpg"; 35 35 36 36 if($pid == -1 || !file_exists($img_uri)) { //for specific image resizging, caching is not required. it'll be saved with -1 pid … … 40 40 41 41 //Actual image url 42 $resized_img = WP_PLUGIN_URL . "/amtythumb/cache/". $pid . "_" . $w . "_" . $h . ".jpg";42 $resized_img = getAmtyThumbCacheURL() . $pid . "_" . $w . "_" . $h . ".jpg"; 43 43 44 44 if($img_url_only == "y"){ -
amtythumb/trunk/readme.txt
r777391 r779794 5 5 Requires at least: 2.5 6 6 Tested up to: 3.5 7 Stable tag: 3.2.07 Stable tag: 4.0.0 8 8 9 9 Fetch first image of a post and Resize it. Otherwise resize an image. … … 94 94 == Changelog == 95 95 96 = 4.0.0 = 97 * cache outside plugin folder. So your cache doesnt get empty on plugin update 98 * offline cache - You can rebuild cache for all or particular posts directly through option page. It saves client response time for posts which are not cached yet. 99 * HTML design fix amty thumb option page. 100 96 101 = 3.2.0 = 97 102 * improved quality of PNG and GIF files resizing … … 137 142 == Upgrade Notice == 138 143 144 = 4.0.0 = 145 * cache outside plugin folder. So your cache doesnt get empty on plugin update 146 * offline cache - You can rebuild cache for all or particular posts directly through option page. It saves client response time for posts which are not cached yet. 147 * HTML design fix amty thumb option page. 148 139 149 = 3.2.0 = 140 150 * improved quality of PNG and GIF files resizing 141 142 = 3.1.1 =143 * direct recache link.144 151 145 152 = 3.0.1 =
Note: See TracChangeset
for help on using the changeset viewer.