Changeset 178651
- Timestamp:
- 12/02/2009 04:03:19 AM (16 years ago)
- Location:
- auto-post-images-api/trunk
- Files:
-
- 1 added
- 4 edited
-
auto-post-images.php (modified) (21 diffs)
-
css/kkapiadmin.css (added)
-
php/Filesystem.class.php (modified) (1 diff)
-
php/ThumbCreator.class.php (modified) (2 diffs)
-
readme.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
auto-post-images-api/trunk/auto-post-images.php
r155924 r178651 3 3 Plugin Name: Auto Post Images (API) 4 4 Plugin URI: http://www.karthikeyankarunanidhi.com 5 Version: 2. 25 Version: 2.3 6 6 Author: <a href="http://www.karthikeyankarunanidhi.com">Karthikeyan Karunanidhi</a> 7 7 Description: Automatically adds images to posts without having to edit the post. … … 87 87 88 88 /** 89 * Width of the thumbnails 90 */ 91 var $iThumbnailWidth = 100; 92 93 /** 94 * Style class to apply to images 95 */ 96 var $sImageClass = ''; 97 98 /** 99 * Style class to apply the the image container 100 */ 101 var $sContainerClass = ''; 102 103 /** 89 104 * Plugin settings 90 105 */ … … 97 112 "sImageThumbnailDirUrl" => '', 98 113 "sImageCacheDir" => '', 99 "sRegEx" => "^Image___POSTID__[^0-9]*\.[a-zA-Z]+$", 100 "bOptmizeImagesForSearch" => 'NO' 114 "sRegEx" => "^api__POSTID__[^\.]*\.[a-zA-Z]+$", 115 "bOptmizeImagesForSearch" => 'NO', 116 "sImageClass" => '', 117 "sContainerClass" => '', 118 "iThumbnailWidth" => 100 101 119 ); 102 120 /** … … 105 123 * the postid before searching for images 106 124 */ 107 var $sRegEx = "^ Image___POSTID__[^0-9]*\.[a-zA-Z]+$";125 var $sRegEx = "^api__POSTID__[^\.]*\.[a-zA-Z]+$"; 108 126 109 127 /** 110 128 * Default regular expression to use when searching for images associated with a post. 111 129 */ 112 var $sDefaultRegEx = "^ Image___POSTID__[^0-9]*\.[a-zA-Z]+$";130 var $sDefaultRegEx = "^api__POSTID__[^\.]*\.[a-zA-Z]+$"; 113 131 114 132 /** 115 133 * Default regular expression to use when renaming images for SEO 116 134 */ 117 var $sImageSEOPrefix = " api";135 var $sImageSEOPrefix = "sapi"; 118 136 var $sImageSEOPattern = ''; 137 var $sImageSEOPatternMatched = ''; 119 138 120 139 /** … … 123 142 function KKAutoPostImages () { 124 143 125 $this->sImageSEOPattern = '^' . $this->sImageSEOPrefix . '[0-9]+_'; 144 $this->sImageSEOPattern = '^' . $this->sImageSEOPrefix . '[0-9]+'; 145 $this->sImageSEOPatternMatched = '^' . $this->sImageSEOPrefix . '([0-9]+)'; 126 146 127 147 $this->init(); … … 144 164 $this->sDefaultImageUrl = $this->sImageDirUrl . $this->sDefaultImageName; 145 165 166 $this->sImageClass = $this->aAdminOptions['sImageClass']; 167 $this->sContainerClass = $this->aAdminOptions['sContainerClass']; 168 169 $this->iThumbnailWidth = ( empty($this->aAdminOptions['iThumbnailWidth']) || !is_numeric($this->aAdminOptions['iThumbnailWidth']) ) ? 100 : $this->aAdminOptions['iThumbnailWidth']; 170 146 171 if ($this->aAdminOptions['bOptmizeImagesForSearch'] == 'YES') { 147 172 148 $this->sRegEx = '^' . $this->sImageSEOPrefix . '__POSTID__ _'; //[^\n]*\.[^\n]+$';173 $this->sRegEx = '^' . $this->sImageSEOPrefix . '__POSTID__'; //[^\n]*\.[^\n]+$'; 149 174 150 175 } else { … … 261 286 } 262 287 263 $sHtml .= '<div class="kkautopostimage ">';288 $sHtml .= '<div class="kkautopostimage '.$this->sContainerClass.'">'; 264 289 265 290 foreach($aImageUrls as $sImageName => $sImageUrl) { … … 287 312 $oThumbs = new ThumbCreator(); 288 313 289 $bStatus = $oThumbs->createThumbnail($this->sImageDirPath, $sImageFilePath, $sThumbnailPath );314 $bStatus = $oThumbs->createThumbnail($this->sImageDirPath, $sImageFilePath, $sThumbnailPath, $this->iThumbnailWidth); 290 315 291 316 if( $bStatus === FALSE ) { … … 300 325 $sThumbSearchTags = str_replace('-', ' ', $sThumbSearchName); 301 326 302 $sHtml .= "<a href=\"{$sImageUrl}\" rel=\"ibox\" title=\" \"><img src=\"{$sThumbnailUrl}\" alt=\"{$sThumbSearchTags}\" title=\"Click to enlarge\" /></a><br />"; 327 //echo '<pre>', print_r($post, TRUE), '</pre>'; 328 329 $sHtml .= "<a href=\"{$sImageUrl}\" rel=\"ibox\" title=\" \"><img src=\"{$sThumbnailUrl}\" class=\"{$this->sImageClass}\" alt=\"{$sThumbSearchTags}\" title=\"".ucwords($post->post_title)."\" /></a><br />"; 303 330 } 304 331 … … 314 341 315 342 echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/auto-post-images-api/css/kkimageinpost.css" />' . "\n"; 343 } 344 345 /** 346 * Hooked into 'admin_head' and inserts the css <link> tag into the pages <head> 347 */ 348 function includeAdminCSS() { 349 echo '<link type="text/css" rel="stylesheet" href="' . get_bloginfo('wpurl') . '/wp-content/plugins/auto-post-images-api/css/kkapiadmin.css" />' . "\n"; 316 350 } 317 351 … … 366 400 $aAdminOptions['sImageThumbnailDirUrl'] = $this->sImageThumbnailDirUrl; 367 401 $aAdminOptions['sImageCacheDir'] = $this->sImageCacheDir; 402 $aAdminOptions['sImageClass'] = $this->sImageClass; 403 $aAdminOptions['sContainerClass'] = $this->sContainerClass; 404 405 $aAdminOptions['iThumbnailWidth'] = $this->iThumbnailWidth; 368 406 369 407 if (isset($_POST['updateAutoPostImagesSettings'])) { … … 421 459 } 422 460 461 if (isset($_POST['AutoPostImagesImageClass'])) { 462 463 $aAdminOptions['sImageClass'] = $_POST['AutoPostImagesImageClass']; 464 } 465 466 if (isset($_POST['AutoPostImagesContainerClass'])) { 467 468 $aAdminOptions['sContainerClass'] = $_POST['AutoPostImagesContainerClass']; 469 } 470 471 if (isset($_POST['AutoPostImagesThumbnailWidth'])) { 472 473 $aAdminOptions['iThumbnailWidth'] = ( !empty($_POST['AutoPostImagesThumbnailWidth']) ) ? $_POST['AutoPostImagesThumbnailWidth'] : $aAdminOptions['iThumbnailWidth']; 474 } 475 423 476 if ( !ereg("/$", $aAdminOptions['sImageDirPath']) ) { 424 477 425 $aAdminOptions['sImageDirPath'] = $aAdminOptions['sImageDirPath'] . ' /';478 $aAdminOptions['sImageDirPath'] = $aAdminOptions['sImageDirPath'] . '\\'; 426 479 } 427 480 428 481 if ( !ereg("/$", $aAdminOptions['sImageThumbnailDirPath']) ) { 429 482 430 $aAdminOptions['sImageThumbnailDirPath'] = $aAdminOptions['sImageThumbnailDirPath'] . ' /';483 $aAdminOptions['sImageThumbnailDirPath'] = $aAdminOptions['sImageThumbnailDirPath'] . '\\'; 431 484 } 432 485 … … 443 496 if ( !ereg("/$", $aAdminOptions['sImageCacheDir']) ) { 444 497 445 $aAdminOptions['sImageCacheDir'] = $aAdminOptions['sImageCacheDir'] . '/'; 446 } 498 $aAdminOptions['sImageCacheDir'] = $aAdminOptions['sImageCacheDir'] . '\\'; 499 } 500 501 $aAdminOptions = array_map('stripslashes_deep', $aAdminOptions); 502 503 //echo '<pre>', print_r($aAdminOptions, TRUE), '</pre>'; 447 504 448 505 update_option($this->sAdminOptionsName, $aAdminOptions); 506 507 if (isset($_POST['AutoPostImagesRerun']) && $_POST['AutoPostImagesRerun'] == 'rerun') { 508 509 //echo '<pre>', print_r($_POST, TRUE), '</pre>'; 510 511 $sRerunStatus = $this->rerunImagesProcesses(); 512 513 if($bRerunStatus !== FALSE) { 514 515 echo $sRerunStatus; 516 } 517 } 449 518 450 519 echo '<div class="updated"><p><strong>' . __("Settings Updated.", "KKAutoPostImages") . '</strong></p></div>'; … … 507 576 508 577 echo " 509 <div class=\" wrap\">578 <div class=\"kkwrap\"> 510 579 511 580 <form method=\"post\" action=\"{$sRequestUri}\"> … … 513 582 <h2>Auto Post Images (API) Settings</h2> 514 583 515 <h3>Display default image if not image is found?</h3> 516 517 <p> 518 <input type=\"radio\" id=\"AutoPostImagesDisplayDefaultImages_yes\" name=\"AutoPostImagesDisplayDefaultImages\" value=\"YES\" {$sDisplayDefaultImageYesRadio} /> <label for=\"AutoPostImagesDisplayDefaultImages_yes\">Yes</label> 519 <input type=\"radio\" id=\"AutoPostImagesDisplayDefaultImages_no\" name=\"AutoPostImagesDisplayDefaultImages\" value=\"NO\" {$sDisplayDefaultImageNoRadio} /> <label for=\"AutoPostImagesDisplayDefaultImages_no\">No</label> 520 </p> 521 522 <p>Selecting "No" will hide the default "Image coming soon" image if no images are found for the post.</p> 523 524 <h3>Use thumbnails to link to full size images?</h3> 525 526 <p> 527 <input type=\"radio\" id=\"AutoPostImagesUseThumbnails_yes\" name=\"AutoPostImagesUseThumbnails\" value=\"YES\" {$sUseThumbnailsYesRadio} /> <label for=\"AutoPostImagesUseThumbnails_yes\">Yes</label> 528 <input type=\"radio\" id=\"AutoPostImagesUseThumbnails_no\" name=\"AutoPostImagesUseThumbnails\" value=\"NO\" {$sUseThumbnailsNoRadio} /> <label for=\"AutoPostImagesUseThumbnails_no\">No</label> 529 </p> 530 531 <p>Selecting "Yes" will use thumbnail images in the post to link to full size images.</p> 532 533 <h3>Image search Regular Expression?</h3> 534 535 <p> 536 <input type=\"text\" size=\"75\" id=\"AutoPostImagesRegEx\" name=\"AutoPostImagesRegEx\" value=\"$aAdminOptions[sRegEx]\" /> 537 </p> 538 539 <p> 540 Regular expression to use when searching for images associated with a post. Must have __POSTID__ somewhere in the expression which will be replaced with the actual post id before searching. 541 </p> 542 543 <p> 544 <strong>Note: </strong>If <em>Rename images for SEO</em> (below) is enabled then images uploaded must still be named according to the regular expression specified here. The plugin will automatically rename images for SEO. 545 </p> 546 547 <h3>Rename images for SEO?</h3> 548 549 <p> 550 <input type=\"radio\" id=\"AutoPostImagesOptmizeImagesForSearch_yes\" name=\"AutoPostImagesOptmizeImagesForSearch\" value=\"YES\" {$sOptmizeImagesForSearchYesRadio} onClick=\"javascript:alert('Ensure that images uploaded are named according to the regular expression specified in Image search Regular Expression (above). The plugin will automatically rename images for SEO.')\" /> <label for=\"AutoPostImagesOptmizeImagesForSearch_yes\">Yes</label> 551 <input type=\"radio\" id=\"AutoPostImagesOptmizeImagesForSearch_no\" name=\"AutoPostImagesOptmizeImagesForSearch\" value=\"NO\" {$sOptmizeImagesForSearchNoRadio} /> <label for=\"AutoPostImagesOptmizeImagesForSearch_no\">No</label> 552 </p> 553 554 <p>Selecting "Yes" will use rename the images using the POST title so that the images names are optimized for search.</p> 555 556 <p> 557 <strong>Note: </strong>Ensure that images uploaded are named according to the regular expression specified in <em>Image search Regular Expression</em> (above). The plugin will automatically rename images for SEO. 558 </p> 559 560 <h3>Image directory?</h3> 561 562 <p> 563 <input type=\"text\" size=\"75\" id=\"AutoPostImagesImgDir\" name=\"AutoPostImagesImgDir\" value=\"$aAdminOptions[sImageDirPath]\" /> 564 </p> 565 566 <h3>Thumbnail directory?</h3> 567 568 <p> 569 <input type=\"text\" size=\"75\" id=\"AutoPostImagesThumbDir\" name=\"AutoPostImagesThumbDir\" value=\"$aAdminOptions[sImageThumbnailDirPath]\" /> 570 </p> 571 572 <h3>Image directory URL?</h3> 573 574 <p> 575 <input type=\"text\" size=\"75\" id=\"AutoPostImagesImgUrl\" name=\"AutoPostImagesImgUrl\" value=\"$aAdminOptions[sImageDirUrl]\" /> 576 </p> 577 578 <h3>Thumbnail directory URL?</h3> 579 580 <p> 581 <input type=\"text\" size=\"75\" id=\"AutoPostImagesThumbUrl\" name=\"AutoPostImagesThumbUrl\" value=\"$aAdminOptions[sImageThumbnailDirUrl]\" /> 582 </p> 583 584 <h3>Cache directory? (Used by the thumbnail creator)</h3> 585 586 <p> 587 <input type=\"text\" size=\"75\" id=\"AutoPostImagesCacheDir\" name=\"AutoPostImagesCacheDir\" value=\"$aAdminOptions[sImageCacheDir]\" /> 588 </p> 584 <fieldset class=\"kkfieldset\"> 585 <legend>General Settings</legend> 586 587 <h3>Display default image if not image is found?</h3> 588 589 <p> 590 <input type=\"radio\" id=\"AutoPostImagesDisplayDefaultImages_yes\" name=\"AutoPostImagesDisplayDefaultImages\" value=\"YES\" {$sDisplayDefaultImageYesRadio} /> <label for=\"AutoPostImagesDisplayDefaultImages_yes\">Yes</label> 591 <input type=\"radio\" id=\"AutoPostImagesDisplayDefaultImages_no\" name=\"AutoPostImagesDisplayDefaultImages\" value=\"NO\" {$sDisplayDefaultImageNoRadio} /> <label for=\"AutoPostImagesDisplayDefaultImages_no\">No</label> 592 </p> 593 594 <p>Selecting "No" will hide the default "Image coming soon" image if no images are found for the post.</p> 595 596 <h3>Use thumbnails to link to full size images?</h3> 597 598 <p> 599 <input type=\"radio\" id=\"AutoPostImagesUseThumbnails_yes\" name=\"AutoPostImagesUseThumbnails\" value=\"YES\" {$sUseThumbnailsYesRadio} /> <label for=\"AutoPostImagesUseThumbnails_yes\">Yes</label> 600 <input type=\"radio\" id=\"AutoPostImagesUseThumbnails_no\" name=\"AutoPostImagesUseThumbnails\" value=\"NO\" {$sUseThumbnailsNoRadio} /> <label for=\"AutoPostImagesUseThumbnails_no\">No</label> 601 </p> 602 603 <p>Selecting "Yes" will use thumbnail images in the post to link to full size images.</p> 604 605 <h3>Customize appearance</h3> 606 607 <p> 608 <label class=\"kklabel\">Container style class: </label><input type=\"text\" class=\"kkwidth20\" id=\"AutoPostImagesContainerClass\" name=\"AutoPostImagesContainerClass\" value=\"$aAdminOptions[sContainerClass]\" /> (Class names specified here is applied to the <em>div</em> that contains the images.) 609 </p> 610 611 <p> 612 <label class=\"kklabel\">Image style class: </label><input type=\"text\" class=\"kkwidth20\" id=\"AutoPostImagesImageClass\" name=\"AutoPostImagesImageClass\" value=\"$aAdminOptions[sImageClass]\" /> (Class names specified here is applied to the images.) 613 </p> 614 615 <p> 616 <label class=\"kklabel\">Thumbnail width (px): </label><input type=\"text\" class=\"kkwidth20\" id=\"AutoPostImagesThumbnailWidth\" name=\"AutoPostImagesThumbnailWidth\" value=\"$aAdminOptions[iThumbnailWidth]\" /> (Width of the thumbnails generated. The height is automatically calculated to maintain the aspect ratio. Changes are applied to any new thumbnails generated. If you wish to apply the new width to existing thumbnails then enable Maintenance functions at the end of this page.) 617 </p> 618 619 <h3>Image search Regular Expression?</h3> 620 621 <p> 622 <input type=\"text\" size=\"75\" id=\"AutoPostImagesRegEx\" name=\"AutoPostImagesRegEx\" value=\"$aAdminOptions[sRegEx]\" /> (Regular expression to use when searching for images associated with a post. Must have __POSTID__ somewhere in the expression which will be replaced with the actual post id before searching.) 623 </p> 624 625 <p> 626 <strong>Note: </strong>If <em>Rename images for SEO</em> (below) is enabled then images uploaded must still be named according to the regular expression specified here. The plugin will automatically rename images for SEO. 627 </p> 628 629 <h3>Rename images for SEO?</h3> 630 631 <p> 632 <input type=\"radio\" id=\"AutoPostImagesOptmizeImagesForSearch_yes\" name=\"AutoPostImagesOptmizeImagesForSearch\" value=\"YES\" {$sOptmizeImagesForSearchYesRadio} onClick=\"javascript:alert('Ensure that images uploaded are named according to the regular expression specified in Image search Regular Expression (above). The plugin will automatically rename images for SEO.')\" /> <label for=\"AutoPostImagesOptmizeImagesForSearch_yes\">Yes</label> 633 <input type=\"radio\" id=\"AutoPostImagesOptmizeImagesForSearch_no\" name=\"AutoPostImagesOptmizeImagesForSearch\" value=\"NO\" {$sOptmizeImagesForSearchNoRadio} /> <label for=\"AutoPostImagesOptmizeImagesForSearch_no\">No</label> 634 </p> 635 636 <p>Selecting "Yes" will rename the images using the POST title so that the images names are optimized for indexing by search engines.</p> 637 638 <p> 639 <strong>Note: </strong>Ensure that images uploaded are named according to the regular expression specified in <em>Image search Regular Expression</em> (above). The plugin will automatically rename images for SEO. For example: If <em>Image search Regular Expression</em> is set to \"^api__POSTID__[^.]*.[a-zA-Z]+$\" then you will upload images for POST #3 as <em>api3.jpg</em> and the SEO process will rename it as <em>sapi3_the-title-of-the-post_0.jpg</em> and the thumbnail will be named <em>thumb_sapi3_the-title-of-the-post_0.jpg</em> 640 </p> 641 642 <h3>Image directory?</h3> 643 644 <p>This is the location where you will be putting all the images. You should change this from the default to a folder outside the plugin directory.</p> 645 646 <p> 647 <input type=\"text\" class=\"kkwidth90\" id=\"AutoPostImagesImgDir\" name=\"AutoPostImagesImgDir\" value=\"$aAdminOptions[sImageDirPath]\" /> 648 </p> 649 650 <h3>Thumbnail directory?</h3> 651 652 <p>This is where the thumbnails generated by the plugin are stored. You should change this from the default to a folder outside the plugin directory.</p> 653 654 <p> 655 <input type=\"text\" class=\"kkwidth90\" id=\"AutoPostImagesThumbDir\" name=\"AutoPostImagesThumbDir\" value=\"$aAdminOptions[sImageThumbnailDirPath]\" /> 656 </p> 657 658 <h3>Cache directory? (Used by the thumbnail creator)</h3> 659 660 <p>This is the directory used by the plugin as cache location when generating thumbnails. Ensure that the plugin has write permissions for this folder.</p> 661 662 <p> 663 <input type=\"text\" class=\"kkwidth90\" id=\"AutoPostImagesCacheDir\" name=\"AutoPostImagesCacheDir\" value=\"$aAdminOptions[sImageCacheDir]\" /> 664 </p> 665 666 <h3>Image directory URL?</h3> 667 668 <p>This the url to the directory where the images are stored.</p> 669 670 <p> 671 <input type=\"text\" class=\"kkwidth90\" id=\"AutoPostImagesImgUrl\" name=\"AutoPostImagesImgUrl\" value=\"$aAdminOptions[sImageDirUrl]\" /> 672 </p> 673 674 <h3>Thumbnail directory URL?</h3> 675 676 <p>This is the url to the directory where the thumbnails are stored.</p> 677 678 <p> 679 <input type=\"text\" class=\"kkwidth90\" id=\"AutoPostImagesThumbUrl\" name=\"AutoPostImagesThumbUrl\" value=\"$aAdminOptions[sImageThumbnailDirUrl]\" /> 680 </p> 681 682 </fieldset> 683 684 <hr style=\"border:1px dashed #888;margin:20px 0;\" /> 685 686 <fieldset class=\"kkfieldset\"> 687 <legend>Maintenance</legend> 688 689 <h3>Rerun image maintenence functions?</h3> 690 691 <p> 692 <input type=\"checkbox\" id=\"AutoPostImagesRerun\" value=\"rerun\" name=\"AutoPostImagesRerun\" value=\"$aAdminOptions[bRerun]\" /> Yes! Re-generate thumbnails & SEO renaming (if enabled). 693 </p> 694 695 <p> 696 <strong>Note:</strong> If checked the plugin will delete & re-generate all thumbnails folder, rename all images for SEO (if enabled). Use this to clean-up the thumbnails and ensure that all the images are named appropriately. 697 </p> 698 </fieldset> 589 699 590 700 <div class=\"submit\"> … … 596 706 } 597 707 598 function renameImagesForSEO() { 599 600 global $post; 601 602 $sThumbSearchName = $post->post_name; 708 function renameImagesForSEO($iPostId = FALSE, $sPostName = '') { 709 710 if($iPostId === FALSE || is_numeric($iPostId) === FALSE) { 711 712 global $post; 713 714 $iPostId = $this->iPostId; 715 $sPostName = $post->post_name; 716 } 717 718 $sThumbSearchName = $sPostName; 603 719 $sThumbSearchTags = str_replace('-', ' ', $sThumbSearchName); 604 720 $iImageSeoCount = 0; … … 608 724 // 609 725 610 $aImageFiles = $this->getImagesForThisPost($ this->iPostId, $this->aAdminOptions['sRegEx']);726 $aImageFiles = $this->getImagesForThisPost($iPostId, $this->aAdminOptions['sRegEx']); 611 727 612 728 foreach($aImageFiles as $sKey => $sImageName) { … … 625 741 do { 626 742 627 $sNewSeoImageName = $this->sImageSEOPrefix . $ this->iPostId . '_' . $sThumbSearchName . '_' . $iImageSeoCount++ . '.' . $sExtn;743 $sNewSeoImageName = $this->sImageSEOPrefix . $iPostId . '_' . $sThumbSearchName . '_' . $iImageSeoCount++ . '.' . $sExtn; 628 744 $sNewSeoThumbImageName = 'thumb_' . $sNewSeoImageName; 629 745 … … 631 747 $sNewThumbImageFilePath = $this->sImageThumbnailDirPath . $sNewSeoThumbImageName; 632 748 633 } while (is_file($sNew SeoImageName) === TRUE);749 } while (is_file($sNewImageFilePath) === TRUE); 634 750 635 751 //echo "<p>rename {$sImageName} to {$sNewImageFilePath}</p>"; … … 649 765 rename($sThumbImageFilePath, $sNewThumbImageFilePath); 650 766 } 767 768 } else { 769 770 // 771 //echo "<p>{$sImageName} does not need SEO renaming</p>"; 651 772 } 652 773 } 653 774 } 775 } 776 777 function rerunImagesProcesses() { 778 779 $aImageTypes = array(); 780 781 $oFileSys = new Filesystem(); 782 $sStatus = '<div class="updated"><p><strong>' . __("Running maintenance methods on images.", "KKAutoPostImages") . '</strong></p>'; 783 784 // 785 // Delete all the thumbnails 786 // 787 $aThumbnails = $oFileSys->readDir($this->sImageThumbnailDirPath); 788 789 //echo '<pre>', print_r($aThumbnails, TRUE), '</pre>'; 790 791 foreach($aThumbnails as $sThumbnailPath) { 792 793 //echo "<p>{$this->sImageThumbnailDirPath} {$sThumbnailPath}</p>"; 794 795 unlink($this->sImageThumbnailDirPath.$sThumbnailPath); 796 } 797 798 $sStatus .= '<p>- ' . __("Deleted all thumbnails.", "KKAutoPostImages") . '</p>'; 799 800 $aPostIds = array(); 801 802 // 803 // Run SEO on image names 804 // 805 if ($this->aAdminOptions['bOptmizeImagesForSearch'] == 'YES') { 806 807 $aPostsList = get_posts(''); 808 809 foreach($aPostsList as $post) { 810 811 //echo $post->ID; 812 //echo '<pre>', print_r($post, TRUE), '</pre>'; 813 814 $aPostIds[$post->ID] = $post->ID; 815 $this->renameImagesForSEO($post->ID, $post->post_name); 816 } 817 } 818 819 $sStatus .= '<p> - ' . __("Optimied all image names for search engine optimization.", "KKAutoPostImages") . '</p>'; 820 821 // 822 // Locate images that are not associated with any POSTs & images that are not named correctly 823 // 824 $aImages = $oFileSys->readDir($this->sImageDirPath); 825 826 $aImagePostIds = array(); 827 828 $sRegExMatched = $this->aAdminOptions['sRegEx']; 829 830 foreach($aImages as $sImagePath) { 831 832 //echo "<p>{$this->sImageDirPath} {$sImagePath}</p>"; 833 834 if( eregi($this->sImageSEOPatternMatched, $sImagePath) ) { 835 836 //$aImageTypes['seo'][] = $sImagePath; 837 838 } else if(eregi($sRegExMatched, $sImagePath)) { 839 840 $aImageTypes['Non SEO Images'][] = $sImagePath; 841 842 } else { 843 844 $aImageTypes['Unknown Images'][] = $sImagePath; 845 } 846 } 847 848 $sImageProperties = '<strong>Report:</strong><ul class="kkreportui">'; 849 foreach($aImageTypes as $sImageType => $aImageList) { 850 851 $sImageProperties .= "<li><strong>{$sImageType}</strong><ul class=\"kkreportui2\">"; 852 853 foreach($aImageList as $sImage) { 854 855 $sImageProperties .= "<li>{$sImage}</li>"; 856 } 857 858 $sImageProperties .= "</ul></li>"; 859 } 860 $sImageProperties .= "</ul>"; 861 862 $sStatus .= '<p> - ' . __("Examining all images.", "KKAutoPostImages") . '</p>' . "<p>{$sImageProperties}</p>"; 863 864 //echo '<pre>', print_r($aImageTypes, TRUE), '</pre>'; 865 866 $sStatus .= '<p /><p><strong>' . __("Maintenance complete.", "KKAutoPostImages") . '</strong></p>'; 867 868 $sStatus .= '</div>'; 869 870 return $sStatus; 654 871 } 655 872 … … 675 892 if ( function_exists('add_options_page') ) { 676 893 677 add_options_page('Auto Post Images (API) Settings', 'Auto Post Images (API) Settings', 9, basename(__FILE__), array(&$oKKAutoPostImages, 'printAdminPage')); 894 $mypage = add_options_page('Auto Post Images (API) Settings', 'Auto Post Images (API) Settings', 9, basename(__FILE__), array(&$oKKAutoPostImages, 'printAdminPage')); 895 896 add_action( "admin_print_scripts-$mypage", array(&$oKKAutoPostImages, 'includeAdminCSS'), 1); 678 897 } 679 898 } -
auto-post-images-api/trunk/php/Filesystem.class.php
r72153 r178651 63 63 } else { 64 64 65 if($sFileRegEx !== FALSE && !ereg ($sFileRegEx, $file)) {65 if($sFileRegEx !== FALSE && !eregi($sFileRegEx, $file)) { 66 66 67 67 continue; -
auto-post-images-api/trunk/php/ThumbCreator.class.php
r90273 r178651 16 16 } 17 17 18 function createThumbnail ($sImageDir, $sImageFilePath, $sThumbnailFilePath ) {18 function createThumbnail ($sImageDir, $sImageFilePath, $sThumbnailFilePath, $iThumbnailWidth = 100) { 19 19 20 20 // create phpThumb object … … 22 22 $oThumb = new phpThumb(); 23 23 24 // thumbnail width25 //26 $iThumbnailWidth = 100;27 24 $sCache = dirname(__FILE__) . '/phpThumb/cache/'; 28 25 -
auto-post-images-api/trunk/readme.txt
r155929 r178651 4 4 Tags: auto,automatic,image,images,post,recipe,recipes,cook,cooking,chef,kitchen,photo,blog,photos 5 5 Requires at least: 2.6.2 6 Tested on: 2.6.2, 2.7, 2.7.1, 2.8.4 7 Tested up to: 2.8. 48 Stable tag: 2. 26 Tested on: 2.6.2, 2.7, 2.7.1, 2.8.4,2.8.6 7 Tested up to: 2.8.6 8 Stable tag: 2.3 9 9 10 10 Automatically adds images to posts without having to edit the post. … … 24 24 Images tagged with the POSTID are displayed on that post. If the thumbnail option is enabled the plugin will use thumbnails in the post to link to the full size images. The plugin will automatically create thumbnails when needed. 25 25 26 Usage: Upload images by naming them as `' Image_POSTID'` where 'POSTID' is ID of post where the image should be displayed. If you wish to use a different filename format then you can edit the regular expression pattern in the settings page.26 Usage: Upload images by naming them as `'apiPOSTID'` where 'POSTID' is ID of post where the image should be displayed. If you wish to use a different filename format then you can edit the regular expression pattern in the settings page. 27 27 28 28 Multiple images can be attached to a post simply by ensuring that all of them have the same prefix. For posts that do not have images a default "Image coming soon" image is displayed; this can be disabled from the settings screen. 29 29 30 Example Image Name: `' Image_66.jpg', 'Image_66_a.jpeg', 'Image_66_two.gif', 'Image_66something'`, etc. Note: When posting multiple images to the same post by naming them with the same 'Image_NNN' prefix the image name after the prefix cannot have numbers. For example: `'Image_66abc2xyx.gif'` is not allowed because the filename after the prefix has a number, in this case the number "2". Again, if you wish to use a different filename format then you can edit the regular expression pattern in the settings page.30 Example Image Name: `'api66.jpg', 'api66a.jpeg', 'api66_two.gif', 'api66something'`, etc. Note: When posting multiple images to the same post by naming them with the same 'apiNNN' prefix. Avoid numbers immediately after the POSTID. For example: `'api662.gif'` will not work if the ID of the POST is 66; instead name it something like `'api66image2.gif'`. Again, if you wish to use a different filename format then you can edit the regular expression pattern in the settings page. 31 31 32 32 Demo: [Dash of Salt & A Pinch of Love](http://sethulakshmi.karunanidhi.com/) … … 83 83 1. Click Auto Post Images (API) Settings 84 84 85 = I want to name the images something other than Image_POSTID ? =85 = I want to name the images something other than apiPOSTID ? = 86 86 87 87 Sure. All you have to do is change the regular expression "**Image search Regular Expression?**". Just make sure it has __POSTID__ somewhere in the expression so that the plugin knows which images are attached to which post. … … 113 113 == Changelog == 114 114 115 = 2.3 = 116 * On Tuesday, December 1, 2009 117 * Added settings page options that will allow users to apply custom CSS classes to the image container, images, and control thumbnail width 118 * Updated default regular expressions 119 * Added "Maintenance" functions to clean-up thumbnails and force renaming of all images for search engine optimization 120 * Removed all inline style code for the admin screen and moved it into an admin-page only css file 121 115 122 = 2.2 = 116 * On 123 * On 12:46:43 AM, Friday, September 18, 2009 117 124 * Added SEO support for images. When enabled the images will renamed using the post title 118 125
Note: See TracChangeset
for help on using the changeset viewer.