|
Cookbook /
ImagesAutoResizingSummary: Creates a small image on the page, with a link to a larger image
Version: 2.0
Status: Stable
Prerequisites: pmwiki-2.0.beta10
Maintainer: PRZ
Categories: Images
Votes:
GoalWhen loading an image, create a smaller image on the page, with a link to a larger image. SolutionThe Minimage module : Please report any problem in the discussion paragraph below or by mail.
Add the following line to local/config.php Notes and comments
UsageSet Img:myimage.jpg If default dimensions are not ok for you, you can impose the dimensions by setting Img:150*800*otherimage.gif Note: the use of '.' as separator for size characterization is no longer accepted. You should remove it to still have working links. - Sorry for that, see the discussion for explanation - Image type is limited to jpeg, gif and png. When clicking on the Img call, a screen will open to invite you to upload your image and create or modify IPTC tags.
After validating the input, the images are resized and stored on the harddrive. To force resizing of an existing image, use a leading star (*), which should be removed later: Img:*220*1024*myimage.jpg Tip: to resize an image, edit the page, add the dimensions to be forced, make a preview, which will drive to image recalculation (not shown because the image is still in the cache), cancel the edit, and force the reload of image with [Shift] + reload button. That way, you have nothing to remove...
If the small image is of same size as the plain image, there will be no link to the plain image. So by example : Img:350*350*AnImage.jpg will simply display the image with a dimension of 350 pixels. There is no size limitation (but your server probably have limitations), but wrong files will be automatically deleted, and too large source images will be resized. This script do not resize images lower than (1.15 * required size) -to limit quality loss when image is slightly larger than required. This coefficient can be modified (parameter $OverSize). Site example :
You can also load images by FTP. They will be resized at first display. In that case, the IPTC tags will be the defaults for caption and special instructions, and the copyright owner will be the first one to display the images... (read on the author cookie). For files loaded via FTP, image extension shall be in lower case.
If plain image is of same size as the archive image, the archive will be automatically deleted. ConfigurationOn PmWiki2 only. Need to have the GD library installed in a version above 2.03 (to allow image resampling). This library is part of the PHP distribution but not always installed, because it is delicate to install, and also use significant server resources. If resizing not possible, a message will be displayed. Needs to have PmWiki uploads enabled. The password is the upload password. Storage directory is the same as for upload. #$WriteGif=FALSE; // Force inactivation of Gif writing # (default TRUE, but check function existence) #$DispIPTC=FALSE; // Stop interactive IPTC input (default TRUE) $img_smallsize = value; //Larger size of displayed image,default 256 $img_plainsize = value; //Larger size of linked image, default 768 $img_archsize = value; //Max size of archive on drive, default 1280 ## Setting archive size equal to linked size remove archive files #$OverSize = value;//extra size which do not allow resizing,default 1.15 ## Default IPTC tags (jpeg images only) $def_iptc_caption = 'text'; # if no caption tag exist, default 'Image collected on a PmWiki' $def_iptc_copyright = 'text'; # if no copyright tag exists and no Author defined, default empty $def_iptc_special = 'text'; # *appended* to existing special instruction tag, default empty. # Maybe used to defined a site licence (cc or artistic or whatever). When interactive IPTC tags are unactivated, parametered values are used, and the Author (as defined in the cookie) is set as copyright owner, if no default author set. To unactivate author setting, set a '-' or any char as default author. TranslationsThe strings to be translated are defined in the PmWiki.XLPageCookbookTemplate page, which is used to create any local XLPageCookbook page. Explanation and user documentation : See also this page translated : Limitations
LicenseGPL History
ContributorCategories: Images
DiscussionTHANKS! This is a nice feature I've really been waiting for! :-) Done on V1.5 PRZ Since installing v1.3 I get for half of my photo's "invalid file extension". what has happened? (I'm using Mac OSX for server and maintenance. the file extension is .jpg) Han It seems that a filename with ONLY numbers (like 123.jpg) is no longer accepted. Renaming part of my uploaded photos has solved the problem. Thanks for the quick reaction, Han Ah, yes, the number is interpreted as the required sized of an empty name. It have been solved on V1.5 by requiring to use only '*' character instead of '.' as separator for size. Made some changes to the code for a change-proposal anyone may figure out for him/herself what can be of use from it... Regards, This is a too special use, so i will not implement anything in the base code. Some suggestions: $flpthPlain = str_replace('.s.','.p.',$flpthSmall);
something like: if (@$_REQUEST['action']=='publish') $flpthPlain = ''; Which will make like if the plain file don't exist and stop the link (in last version). - untested - sounds great but everything goes along fine until I click the upload button and i then get: This happens with any image type, the only difference being that imagecreatefromjpg will change to imagecreatefromgif or imagecreatefrompng etc depending on which type of image i try to upload. all file locations and permissions are correct. any ideas how I might get past this stumbling block? thx It probably means that the GD image library (which should be over 2.03) is not properly installed in the PHP installation. Without that library, this recipe and all others galleries cannot work. The text file in the zip has incorrectly formated the include statment. Should be: include_once('cookbook/minimage.php');
Something, minor. BTW, great script, esp for first time! A couple of enhancements that would be nice:
It would be nice to have something like: Would it be possible to set with "$img_smallsize" the '*width*' of displayed image, instead of the larger size of the images? This would make it possible to display the thumbs in a nice evenly spaced collumn. I have a bug with this recipe : form submiting did nothing but bring back my PmWiki home. I had to change <form enctype='multipart/form-data' action='\
to <form enctype='multipart/form-data' action='\$PageUrl' method='post'>
KzarDotNet February 17, 2006, at 03:48 PM I wish to upload pictures into folder defined in my localmap as Pics. Hi I am constantly getting ErrNoResize message after uploading an gif or jpg and setting the Img: markup to the specific file. The attachment itself gets uploaded and can be attached to the page normally. I tried deactivating gif creation set $WriteGif=FALSE; in the minimage script, this didnt help. Any suggestions? Thanks Boris Seems to work fine, but I do not get an upload form with the image caption/copyright etc as seen above. If I put a fake link in like img:addfile.gif this comes up as a link to upload file and then shows the caption and copyright etc, but does not allow me to change the name of the file from addfile.gif to realname.gif. bouton? Nov 15, 2006 Doesn't work with PmWiki 2.1.27. After uploading a file, it gives
Attach:Img:test2.jpg
on page render. Bianka? Feb 27, 2007 In order to get alpha channels working on pngs and maybe even gifs. find $newimage = imagecreatetruecolor($newwidth, $newheight); after add imagealphablending($newimage, false); and find $typeout=$type; after add imagesavealpha($newimage, true); now when thumbs are made of png's with alpha channels there saved. Scotepi June 17, 2007 Can I add any alternate text for small image? There appears to be a small error in minimage.php. The expression: if (@$_POST["Cancel"]) {
ImgExit($pagename);
}
should be: if (@$_POST["canc"]) {
ImgExit($pagename);
}
to match the <input type='submit' name='canc' value=' Cancel ' /> statement. |