PDA

View Full Version : More Picture dimensions needed!!!



Raivo Vaikla
January 27, 2013, 04:25 PM
Hey.. Is it extremely hard to ad more picture dimensions.. in addition to "Thumbnail" and "Picture".. I need two more - small thumbnail and medium picture.. It's quite useful if you want to show images in different sizes.. and speeds up page load time when you dont have to load full image and scale it like about 50%...

Maybe you can show me a direction - files to change or smth!

Thanks.

Petrache Nicolae
January 27, 2013, 04:34 PM
Hey.. Is it extremely hard to ad more picture dimensions.. in addition to "Thumbnail" and "Picture".. I need two more - small thumbnail and medium picture.. It's quite useful if you want to show images in different sizes.. and speeds up page load time when you dont have to load full image and scale it like about 50%...

Maybe you can show me a direction - files to change or smth!

Thanks.

This is an old thing i have complained about. The script should use small thumbnail and medium picture . Not normal to have 15 images of 300 kb each loaded for each product. we should have 15 thumbnails + 15 medium pictures to be displayed when we are using the carousel and the large image should be used just when you open the image viewer (same implementation wich is available in any major script). Since they did not provide a solution to this i assume that it involves big changes, changes that they do not want to make, even if they know it is wrong

Raivo Vaikla
January 27, 2013, 05:57 PM
Would this be the right place to add other dimensions:
includes/controllers/my_listings.inc.php

from around line 58 to line 193

Don't care much for admin side photo management for now... only front end.

Viktor
January 28, 2013, 03:41 AM
Hello Raivo and Petrache,

It's really extremely hard for create new image type. needs many changes in many files. That's why you should create a new ticket with your request and we will do it like customization for you.

John
January 28, 2013, 08:23 AM
Hello Guys,
Victor is right, it is enough hard task to add one more resize picture dimension to upload process and apply it to your layout,
but I will try to guide you have to add one more image version and save new name to database, it will be your headache how to add it to layout:

NOTE: this instruction suits the Flynax 4.0.1 and 4.1.0 versions only.

1. Open the file: /libs/upload/upload.php and find this code:


'image_versions' => array(
'large' => array(
'prefix' => 'large_',
'max_width' => $GLOBALS['config']['pg_upload_large_width'] ? $GLOBALS['config']['pg_upload_large_width'] : 640,
'max_height' => $GLOBALS['config']['pg_upload_large_height'] ? $GLOBALS['config']['pg_upload_large_height'] : 480,
'watermark' => true
),
'thumbnail' => array(
'prefix' => 'thumb_',
'max_width' => $GLOBALS['config']['pg_upload_thumbnail_width'] ? $GLOBALS['config']['pg_upload_thumbnail_width'] : 120,
'max_height' => $GLOBALS['config']['pg_upload_thumbnail_height'] ? $GLOBALS['config']['pg_upload_thumbnail_height'] : 90,
'watermark' => false
)
)

as you can see there are two current image versions, thumbnail and large image.
2. let's add our new image version like this:


'image_versions' => array(
'large' => array(
'prefix' => 'large_',
'max_width' => $GLOBALS['config']['pg_upload_large_width'] ? $GLOBALS['config']['pg_upload_large_width'] : 640,
'max_height' => $GLOBALS['config']['pg_upload_large_height'] ? $GLOBALS['config']['pg_upload_large_height'] : 480,
'watermark' => true
),
'thumbnail' => array(
'prefix' => 'thumb_',
'max_width' => $GLOBALS['config']['pg_upload_thumbnail_width'] ? $GLOBALS['config']['pg_upload_thumbnail_width'] : 120,
'max_height' => $GLOBALS['config']['pg_upload_thumbnail_height'] ? $GLOBALS['config']['pg_upload_thumbnail_height'] : 90,
'watermark' => false
),
'image_400x300' => array(
'prefix' => 'image_400x300_',
'max_width' => 400,
'max_height' => 300,
'watermark' => false
)
)

I added one more image version by adding one more item to the config array (image_400x300 is our new image version key),
now the system will create one more copy of the uploaded image for us and store it under the same directory with name we specified.

All looks great but we have to add this new copy image name to database, so we have to do:
3. Go to your Admin Panel >> Database and run the following sql query (image_400x300 is our new image version key)


ALTER TABLE `{prefix}_listing_photos` ADD `Image_400x300` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `Thumbnail` ;

3. find this code in the same file:


$insert = array(
'Listing_ID' => $listing_id,
'Position' => $max_pos,
'Photo' => $dir_name . $photo -> large,
'Thumbnail' => $dir_name . $photo -> thumbnail,
'Original' => $config['img_crop_interface'] ? $dir_name . $photo -> name : '',
'Description' => '',
'Type' => 'photo',
'Status' => 'active'
);

and add one more line to the array like this:


$insert = array(
'Listing_ID' => $listing_id,
'Position' => $max_pos,
'Photo' => $dir_name . $photo -> large,
'Thumbnail' => $dir_name . $photo -> thumbnail,
'Image_400x300' => $dir_name . $photo -> image_400x300,
'Original' => $config['img_crop_interface'] ? $dir_name . $photo -> name : '',
'Description' => '',
'Type' => 'photo',
'Status' => 'active'
);


Done, now we have one more copy of the image in the file system and name of new image in the database for each listing photo.
If you have an idea what you need this for, then you know what to do next.

John

Raivo Vaikla
January 28, 2013, 11:56 AM
Perfect! Looks doable to me.. and adding new size options to admin side would also be fairly simple.. I will test it in about 6 hours..
Hope it works.
Thank you very much, John!

John
January 28, 2013, 01:45 PM
Hope it works.
I hope so, let us know if the instruction is proper or not, cheers!

John

Raivo Vaikla
January 28, 2013, 09:18 PM
Hey! Got it working perfectly. I also added 4 lines to tables __config and 4 lines to __lang_keys so I can change size options in admin area.
There is a tricky part though.. Uploading works fine and files are added into database.. But when I choose to crop the uploaded image - new files won't get updated.. I'm gonna look into it but if you can assist me, it would be great!!
Thanks!

autocy
January 29, 2013, 09:52 PM
can we do this only for a specific listing type? like, if i add a listing of type auto, have 3 sizes for pictures, else have only the default two..

autocy
January 31, 2013, 11:19 AM
guys? anyone?

Raivo Vaikla
February 1, 2013, 01:04 AM
I personally think there's no point of separating the creation of thumbnails in such way... you could create all sizes in every category but use only those you want.. i don't know.. anyway it would be way too complicated.. I'm still trying to figure out how to include my new dimensions when people crop photos after uploading..
Cheers!

autocy
February 3, 2013, 10:00 PM
why create thumbnails that you will not use? anyone knows how to add additional dimensions only for a particular listing type??