- Posts: 23
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- creat thumbnail by width and height. you can input height value on K2 control center
creat thumbnail by width and height. you can input height value on K2 control center
- vanshion
-
Topic Author
- Offline
- Junior Member
thanks for Lukas to help me.
here is them
no1
u can only install it
no2
this's about file catalog, u can copy them to already made files
i'm sorry that I have a mistake,don't download tha administrator.rar..thanks
maybe those are not steady , then u can tell me the problem what u runinto trouble.or ask Lukas . he is a great man
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
For example this will crop Small image to square where width and height is taken from width settings:
//Small image
$handle->image_resize = true;
//$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
$handle->image_x = $imageWidth;
$handle->image_y = $imageWidth;
$handle->image_ratio_crop = true;
$handle->Process($savepath);
as you can see 1line is commented out and 2 adeed...
See docs for class.upload.php at verot.net and play with available parameters.
Just add line(s) $handle->somethingofyourchoice
That library create that thums..
Regards,
ln
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
Now,according to your way, it's perfect..then i want to add Height setting on K2 Parameters..it could be?
of course, I have used this way : $handle->image_y = $imageWidth*0.8;
but it's shot of perfection.
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
1. Add required value(s) to administrator\components\com_k2\config.xml
e.g.
param menu="hide" name="itemImageS_height" type="text" default="200" size="4" label="Item Small image height (in px)" description="" /
2. define new variables in mentioned file administrator\components\com_k2\models\item.php
//Small image
$handle->image_resize = true;
//$handle->image_ratio_y = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
$imageHeight = JRequest::getInt('itemImageS_height');
} else {
$imageWidth = $params->get('itemImageS', '200');
$imageHeight = $params->get('itemImageS_height', '200');
}
$handle->image_x = $imageWidth;
$handle->image_y = $imageHeight;
$handle->image_ratio_crop = true;
$handle->Process($savepath);
I have hardcoded this only in models\item.php so i haven't it tested...
Regards,
l
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
thank you very very much~:) i'm going to test it
Lukas said:Yes, but still as a hack... 1. Add required value(s) to administrator\components\com_k2\config.xml e.g.
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
By the way, this is direct way to custom/heavily hacked K2... Without possibility to simple update... :|
Agreed, that images tweaks are (atleast) for me really needed...
Regards,
l
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
First "hardcoded" method definitely works. Here are some screenshots...
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
haha, lukas.
however,we have to modify category.xml as config.xml, so we can set width and height on category config
Lukas said:ok, test it and let us know if it works.. By the way, this is direct way to custom/heavily hacked K2... Without possibility to simple update... :| Agreed, that images tweaks are (atleast) for me really needed... Regards,
l
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
of course,i can input Height value, then ever thumbnail' height equal to half of width
it means that won't work
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
Have you commented out //$handle->image_ratio_y = true; etc ;)
l
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
no error! everthing is normal
you are right! first method work. ($handle->image_y = $imageWidth*0.8; ) this way is work too
however, when i add height setting on K2 then input value of height. it's seem to invalidation. heght is also 200px.
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
Is possible "echo" that values?..
l
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
can u have a try
Lukas said:is new height value from params stored in DB?.. Is possible "echo" that values?.. l
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
1.
2.
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
p.s. "$hanle->image_ration_y=false;" is exact typo? there is ration
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
$imageHeight = JRequest::getInt('itemImageS_height');
} else {
$imageWidth = $params->get('itemImageS', '200');
$imageHeight = $params->get('itemImageS_height', '200');
}
should be? :
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
if (JRequest::getInt('itemImageS_height')) {
$imageHeight = JRequest::getInt('itemImageS_height');
} else {
$imageHeight = $params->get('itemImageS_height', '200');
}
p.s. for clear view, am just frontendguy, so php i guess+assemble+tweak ;)
Please Log in or Create an account to join the conversation.
- vanshion
-
Topic Author
- Offline
- Junior Member
- Posts: 23
it does't matter I follow the first method for the moment. Wishing the next patch will add height setting.
Thank you all the same. Lukas
Lukas said:It looks "doublesized" height. Hard to say without atleast look to your code in both files...
p.s. "$hanle->image_ration_y=false;" is exact typo? there is ration
Please Log in or Create an account to join the conversation.
- vtiger
-
- Offline
- Premium Member
- Posts: 83
Example code from both files:
model/item.php
//Small image
$handle->image_resize = true;
$handle->image_convert = 'jpg';
$handle->jpeg_quality = $params->get('imagesQuality');
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $filename.'_S';
if (JRequest::getInt('itemImageS')) {
$imageWidth = JRequest::getInt('itemImageS');
} else {
$imageWidth = $params->get('itemImageS', '200');
}
if (JRequest::getInt('itemImageS_height')) {
$imageHeight = JRequest::getInt('itemImageS_height');
} else {
$imageHeight = $params->get('itemImageS_height', '200');
}
$handle->image_x = $imageWidth;
$handle->image_y = $imageHeight;
$handle->image_ratio_crop = true;
$handle->Process($savepath);
config.xml (with<> at start and end of course, forum cut out full string...)
param menu="hide" name="itemImageS_height" type="text" default="200" size="4" label="Item Small image height (in px)" description="" /
In config i fill 10 for height and 110 for width and correct (expected=zoom to center and crop to width 110xheight 10) result attached.
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- creat thumbnail by width and height. you can input height value on K2 control center