** This plugin will no longer be updated. **
This plugin does three things:
- It creates rewrite rules that let you create nice urls for your images,
like “http://example.com/image/55/DSC_0001.jpg” instead of “http://example.com/wordpress/wp-content/uploads/2010/02/DSC_0001.jpg””
- It let’s you resize and crop images. And you can add unsharp filter to them too.
- It adds a function, simple_thumbs_img() and with this function you can create ready-to-go IMG-tags
that outputs the correct width and height, even if you choose to resize or crop your image.
Rewrite Rules/Nice Image URLs example
Instead of this URL:
Your image can have this URL, where 55 is the Attachment ID:
Shorter and sweeter.
But there’s more! You can also send in some arguments:
Resize the image to be 150px in width:
Resize the image to be 150px in width, and give it another name (you can name the image to whatever you want)
Resize the image to 150px in height:
Resize the image to stay within 150px in height and width:
Crop the image to exactly 150px in width and height:
Make a small thumb, and also add an unsharp filter:
Make a small thumb, and also add an unsharp filter, and output as png:
Same as above, but with pipe as the delimeter (you can choose between ,._- and |):
Please note that all the resize stuff where made without adding any querystring to the URL.
This is good for Search Engine Optimization (SEO) reasones, but also for caching reasons.
Google Page Speed will for example give you a higher score because of this! 🙂
All generated images will be cached, so only the first call to each URL restults in an actual resize of the image.
Images are also sent with far future expires headers, so if a user returns to your page all images should load blazingly fast.
simple_thumbs_img(): The Magic Function
simple_thumbs_img() generates IMG tags for you, with the correct width & height attributes set, even after resize.
With no width and height values set, the page may be redrawn several times, resulting in a very “jumpy” page.
Using Simple Thumb to create your image tag will solve this problem.
Lack of width and height atributes in img-tags can also lead to
it can’t determine the size of the image.
<?php // get img tag with nice url for image with id 55, with the correct width and height attributes set. // do whatever you wan't with it $img_src = simple_thumbs_img("id=55&tag=1"); // print img tag with nice url for image with id 55, with the correct width and height attributes set. echo simple_thumbs_img("id=55&tag=1"); // print img tag with nice url for image with id 55, and resize it to be a thumb that has the max size 75x75, // with the correct width and height attributes set. echo simple_thumbs_img("id=55&tag=1&w=75&h=75"); // print img tag with nice url for image with id 55, and crop it to be a thumb that has the excact size 75x75, //with the correct width and height attributes set, and add an alt text echo simple_thumbs_img("id=55&tag=1&w=75&h=75&m=c&alt=My alternative text"); ?>
Control the way the thumbs are created by adding parameter “m”, as in “mode”.
To learn how they work just experiment a bit.
- within = mw
- crop = mc
- portrait = mp
- landscape = ml
- auto = ma
- unsharp mask – good for making small thumbnails appear to have more detail. Once you’ve gone unsharp, you don’t want to go back! 🙂
u0 for note, u3 for sharpest
Donation and more plugins
- Upload the folder “simple-thumbs” to “/wp-content/plugins/”
- Activate the plugin through the “Plugins” menu in WordPress
- Done! Now start editing your template files. See usage under description for more info.
بررسیای برای این افزونه یافت نشد.
توسعه دهندگان و همکاران
“Simple Thumbs” نرم افزار متن باز است. افراد زیر در این افزونه مشارکت کردهاند.مشارکت کنندگان
- IMG tag can now have a class. For example: $img_src = simple_thumbs_img(“id=55&tag=1&class=’my-image-class'”);
- if id provied is not the id of an image (wp_get_attachment_url returns false) then an empty string is returned. Solves “divided by zero”-errors.
- Ooups, max_files in cache set to 10. Was for debug purposes… :/ set to 5000 now. should be fine for most I hope.
- If cache directory is not found, it tries to create it. It could be deleted by other plugins that also used the cache directory, resulting in broken images.
- If size is not set or size is set but equal to original size, and no quality, filter or output image format is set, the image will not be modified and orginial image is returned. It’s still a good idea to use simple_thumbs_img() because you then get the correct width and height attributes.
- Fixed so plugins wp_minify and autoptimize don’t break the thumbnails.
- First version. Works fine for me. Let me know how your thumbnail-experience is going!