Wiccle.com in Facebook Wiccle.com in Twitter Wiccle.com in LinkedIn Wiccle.com in Youtube RSS from Wiccle.com Wiccle.com in Atom
 
 
 

Thread: Tutorial: Configuring Image Sizes in Uploads and Templates

Started: April 2, 2010, 07:30 PM  ⋅  Zone: Public Forums  ⋅  Category: Install & Modification  ⋅  Posts: 2  ⋅  Views 725
Started by: Markus  ⋅  Description: Details on how to automatically generate images in just the sizes you want them in.
Post #1
Member: Markus  ⋅  Date: April 2, 2010, 07:30 PM  ⋅ Subject: "Tutorial: Configuring Image Sizes in Uploads and Templates"

iWiccle has offered automatic scaling of images for long. Here are detailed notes on how you can customize the auto-scaled image sizes and use them in different contexts.

If you open up /core/variables.php, you'll find the following variables:

$core['image_sizes'] = array("mini"=>60, "thumbnail"=>160, "small"=>250, "medium"=>400, "large"=>600);
$core['save_original_images'] = FALSE;

The first array of sizes correspond to the image sizes you find in the Sidebar image uploader (available when you post content) and in the Builder image uploader (when you edit pages). The size is the maximum height or width of the image, whichever is greater, in pixels.

The sizes can be anything you want, and as many as you want. If you wanted to have a 800px option for example, you could add in "huge"=>800, or for even larger, "massive"=>1024. If the uploaded image is less than the desired size, the largest available size will be copied in instead of an artificially up-scaled version.

If you want to save the original images, you can change the save_original_images value to TRUE. Originals will be available in /uploads/module/ with a new system-given name, while the scaled images are under /uploads/module/thumbs/ with their size prefixes. Be aware that while storing uploaded source images can be good for future purposes, it can also take up large amounts of space! For more information on uploaded file naming and specifications, Read here ».

If you want to change image sizes for a single module (for example if you want large resolution images for your photo gallery), you can add the image_sizes configuration with your custom values into the module's configuration file (modulename_config.php) in the /modules/ folder.

Don't make too many versions, because they all take up disk space. If you know you will only be using images of 60px and 250px in the News module for example, you can change the image_sizes setting in news_config.php to have just these two values, and save the space of the redundant images. (In version 1.21.1, you can also customize JPEG compression quality in configuration files if you are short on space.)

Remember that already uploaded images won't be rescaled. While I have a tool in the works to take care of this (subject to limits imposed by largest available source image size), the image rescaling deal is something to keep in mind in the meantime. (So that your old photos don't stop displaying when you add in new custom sizes, for example.)

Post #2
Member: Markus  ⋅  Date: April 2, 2010, 07:30 PM  ⋅ Subject: "Re: Tutorial: Configuring Image Sizes in Uploads and Templates"

Image Sizes in Dynamic Templates

Instead of hard-coding rescaled image sizes, the templating system uses tags, the values of which can vary between modules. If you open up /templates/pro/skin_post.php, for example, you can see several examples of size tags in action. Below is the HTML tag for an image in post_full format:

<img src="{$tp->con['PATH_UPLOADS']}/[[POST_MODULE_IDENT]]/{$tp->con['PATH_THUMBS']}/s[[POST_IMAGE_FULL]]_[[POST_IMAGE]]" class="post_assoc_image" alt="[[POST_NAME]] - [[CLICK_ENLARGE]]" id="post_[[POST_ID]]_assoc_image" onclick="showLargeImage('general_ajax', '[[POST_IMAGE]]', '[[POST_IMAGE_MAX]]');" />

In the above, when data is parsed into the template from the database, the POST_IMAGE_FULL tag is converted to the size value defined in the module (such as 250 for a 250px sized associated image), and the POST_IMAGE_MAX is the size for the image that opens up in a popup — by default 600px.

To change the default values for image sizes, please refer to the below notes on image size configuration for modules.


Module Image Size Configuration for Templating

If you open up the configuration file of any iWiccle/Wiccle module, you'll find something like the following:

$core['module']['set']['cat_image_full'] = 60;
$core['module']['set']['cat_image_medium'] = 60;
$core['module']['set']['cat_image_sidebar'] = 60;
$core['module']['set']['cat_stream_image'] = 160;

$core['module']['set']['parent_image_full'] = 60;
$core['module']['set']['parent_image_medium'] = 60;
$core['module']['set']['parent_image_sidebar'] = 60;

$core['module']['set']['post_image_max'] = 600;
$core['module']['set']['post_image_full'] = 250;
$core['module']['set']['post_image_medium'] = 160;
$core['module']['set']['post_image_short'] = 60;

These define the sizes that are available as template tags (such as [[POST_IMAGE_FULL]]) across the different dynamic content types (such as posts, parents, categories, and threads). POST_IMAGE_MAX is the value for the largest available image size in this module (generally used for AJAX popup windows to show larger versions of images).

If no image sizes are defined in a module configuration file, the global default values from /core/variables.php are used instead.

In general, any values you set under the ['set'] variables are available as tags for templates. If you wanted to use the tag [[MY_TAG]], for example, you could add $core['module']['set']['my_tag'] = "Something else"; to your configuration files.

 

Install & Modification

Add to Favorites
Public Forums
Category  ⋅  Deploying iWiccle and Wiccle into unique solutions that match your needs.
 

Public Forums

Add to Favorites
Public Forums
Zone  ⋅ Public forum sections for support and discussions. Available for everyone.
 

Zone Categories

 
Questions? Ask us!
Back to Top