Keyword

k2 and image resizing landscape or portrait...

  • Philippe PAVANS
  • Philippe PAVANS's Avatar Topic Author
  • Offline
  • New Member
More
3 years 10 months ago #177870 by Philippe PAVANS
k2 and image resizing landscape or portrait... was created by Philippe PAVANS
Before doing a long job to adapt k2 and a certain template for a very specific photo site, I made sure to set a good repartition of the large choice of resizing and I did a quick test uploading some photos...
I didn't realized that all the photos I used then were landscape oriented.
After days of work I started to transfer more photos and realized then that the resizing is not done in a box, which means, if you set for example 500px in a box mode that the longuest side will be 500px and the other will be adapted to keep your ratio, whatever the orientation of your photo, that how are working Phoca and many other picture dedicated extensions. I have to admit that the "image" setting form of K2 is clear, only asking for the width of each "size", I didn't read carefully enough !

Does anybody would have a solution to hack the resizing process, any extensions ? for some other reasons, photo dedicated joomla extensions doesn't suit my project.

Thanks
Attachments:

Please Log in or Create an account to join the conversation.

  • Philippe PAVANS
  • Philippe PAVANS's Avatar Topic Author
  • Offline
  • New Member
More
3 years 10 months ago #177872 by Philippe PAVANS
Replied by Philippe PAVANS on topic k2 and image resizing landscape or portrait...
Solved
very proud to say : all by myself !

3 files to modified :

in administrator\components\com_k2\models\item.php

look for :
// Large 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.'_L';
                if (JRequest::getInt('itemImageL')) {
                    $imageWidth = JRequest::getInt('itemImageL');
                } else {
                    $imageWidth = $params->get('itemImageL', '600');
                }
                $handle->image_y = $imageWidth;
                $handle->Process($savepath);

and you have to change it to :
// Large image
                
				$handle->image_resize = true;
                $handle->image_ratio = 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.'_L';
                if (JRequest::getInt('itemImageL')) {
                    $imageWidth = JRequest::getInt('itemImageL');
                } else {
                    $imageWidth = $params->get('itemImageL', '600');
                }
                $handle->image_x = $imageWidth;
                $handle->image_y = $imageWidth;
                $handle->Process($savepath);

you have to do that for every size setting XL L S XS etc...


then
components\com_k2\templates\default\item.php

to lok for :
<!-- Item Image -->
        <div class="itemImageBlock">
            <span class="itemImage">
                <a data-k2-modal="image" href="<?php echo $this->item->imageXLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>">
                    <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
                </a>
            </span>

suppression of "style" in img

change it for :
<!-- Item Image -->
        <div class="itemImageBlock">
            <span class="itemImage">
                <a data-k2-modal="image" href="<?php echo $this->item->imageXLarge; ?>" title="<?php echo JText::_('K2_CLICK_TO_PREVIEW_IMAGE'); ?>">
                    <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" />
                </a>
            </span>


components\com_k2\templates\default\latest-item.php

you look for :
<!-- Item Image -->
        <div class="latestItemImageBlock">
            <span class="latestItemImage">
                <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
                    <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px;height:auto;" />
                </a>
            </span>
            <div class="clr"></div>
        </div>

suppression of "style" in img
<!-- Item Image -->
        <div class="latestItemImageBlock">
            <span class="latestItemImage">
                <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
                    <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" />
                </a>
            </span>
            <div class="clr"></div>
        </div>

as we say in french : " OUF !....."
translation : " It's such a relief !!!"

You can do the same operation for others image upload forms of k2 as categorie image and avatar...

Please Log in or Create an account to join the conversation.

  • Philippe PAVANS
  • Philippe PAVANS's Avatar Topic Author
  • Offline
  • New Member
More
3 years 10 months ago #177873 by Philippe PAVANS
Replied by Philippe PAVANS on topic k2 and image resizing landscape or portrait...
Here is the page that tells you everything you have to know about class.upload.php :
www.verot.net/php_class_upload_samples.htm

Please Log in or Create an account to join the conversation.

  • Life Color Communication srl
  • Life Color Communication srl's Avatar
  • Offline
  • New Member
More
10 months 4 days ago #181436 by Life Color Communication srl
Replied by Life Color Communication srl on topic k2 and image resizing landscape or portrait...
HI

Is it possible to keep the name of the image as the original one?

Could you please tell me how to do it?

Thank you

Please Log in or Create an account to join the conversation.

  • Life Color Communication srl
  • Life Color Communication srl's Avatar
  • Offline
  • New Member
More
10 months 1 day ago #181442 by Life Color Communication srl
Replied by Life Color Communication srl on topic k2 and image resizing landscape or portrait...
Good morning

The image that is loaded into K2 is renamed.

I was wondering if it was possible to change the code to keep the original name.

Searching the internet I found information on

joomla-shark but the link has been disabled.

Can you help me?

Thank you

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum