Page 1 sur 1

Control of Scaled Down Images Sizes - Listing

Posté : jeu. 29 avr. 2010 16:41
par Woof
Using the default LISTING template, I have 5 columns. The last column is an "image" column field. The images being shown are scaled down "thumbnails".
Can you please indicate where (which file or code?) can I control this scaling down of the images?
For ex:
350px × 498px (scaled to 100px × 142px)
350px × 240px (scaled to 117px × 80px)
350px × 272px (scaled to 103px × 80px)

I would like to have all the "thumbnails" the same height or the same width. Does it have to do with the coding in file:
administrator/components/com_collector/models/filelist.php?

GREAT Joomla component! BRAVO!
Thank you in advance!
Woof

Re: Control of Scaled Down Images Sizes - Listing

Posté : jeu. 29 avr. 2010 23:12
par steevo
Hi,

The size of images is in file:
components/com_collector/view/collection/view.html.php

Code : Tout sélectionner

/**
	 * @param $fieldId
	 * @param $fieldType
	 * @param $row
	 * @return void
	 */
	function display_field_row($fieldId, $fieldType, $row)
	{
		[...]

		switch($fieldType)
		{
			// line
			case 1:
				[...]
			// text
			case 2:
				[...]
			// define
			case 3:
				[...]
			// image
			case 5:
				$largeurmax=100;
				$hauteurmax=80;
				$image = '';

				if ($row->$value == '')
				{
					// image de substitution
					$image=JPATH_SITE.DS.'components'.DS.'com_collector'.DS.'assets'.DS.'images'.DS.'camera.png'; // adresse de l'image
					$URLimage='./components/com_collector/assets/images/camera.png'; // adresse de l'image
				}
				else
				{
					$image=JPATH_SITE.DS.$row->$value; // adresse de l'image
					if (!file_exists($image)) {
						$image=JPATH_SITE.DS.'components'.DS.'com_collector'.DS.'assets'.DS.'images'.DS.'camera.png'; // adresse de l'image
						$URLimage='./components/com_collector/assets/images/camera.png'; // adresse de l'image
					} else {
						$URLimage='./'.$row->$value; // adresse de l'image
					}
				}

				$taille=getimagesize($image);
				$largeur=$taille[0];
				$hauteur=$taille[1];

				if ( ($hauteur/$hauteurmax) >= ($largeur/$largeurmax) )
				{
					if ($largeur < $largeurmax)
					{
						$size= ' width="'.$largeur.'"';
					}
					else
					{
						$size= ' width="'.$largeurmax.'"';
					}
				}
				else
				{
					if ($hauteur < $hauteurmax)
					{
						$size= ' height="'.$hauteur.'"';
					}
					else
					{
						$size= ' height="'.$hauteurmax.'"';
					}
				}

				echo '<img alt="preview" align="middle" border="1" src="'.$URLimage.'" '.$size.' />';
				break;
In case 5, the image is scaled-down to 100px*80px max
You can change these values to change scale.
This is the only way.
How would you see this configuration in the component ?

Re: Control of Scaled Down Images Sizes - Listing

Posté : ven. 30 avr. 2010 04:24
par Woof
Thank you for the file. I gues I was looking at the wrong place :oops: .
For my use, I made the same value for
$largeurmax=100;
$hauteurmax=100;
and because 90% or more of my images are landscape -horizontal- format, I also change:
if ( ($hauteur/$hauteurmax) >= ($largeur/$largeurmax) )
to
if ( ($hauteur/$hauteurmax) < (less than)= ($largeur/$largeurmax) )

and I find the thumbnails align visually "better" in the default listing mode.
steevo a écrit :In case 5, the image is scaled-down to 100px*80px max
You can change these values to change scale.
This is the only way.
How would you see this configuration in the component ?
And to answer this question, I think I would like to see 2 things here, if I may suggest to you. (I'm not a coder, so please excuse the way I'm expressing this)

1) I think in the image file picker when you choose an image field, it will be nice to borrow from Joomla insert image feature, and have the ALT (DESCRIPTION) and more importantly have the image TITLE tag. No needs for align, and caption, but maybe if caption is not too hard to code... why not have this too!). Right now, the only ALT value for the photo (either in listing or detail) is "preview" found in your coding. Maybe if no description is given, then a default value can be given, such as the default items value? or even the website title?

Alt tags are supposed to only show if you have an image missing, if you want a text box to appear you're supposed to use title="my text".

2) I think, just below this added Description and Title, you could have the thumbnails value added there so people can choose or if no value given, then revert back to a default value.

Hope I expressed correctly what I see/wish.
Again GREAT WORK and THANK YOU to ask for opinion!

Re: Control of Scaled Down Images Sizes - Listing

Posté : sam. 1 mai 2010 18:18
par steevo
Hi,

I made modification for next version:
imageselect.png
(112.35 Kio) Téléchargé 1 fois
So i have added title and description. Description is used for alt attribute and title for title of course.
You will choose height and width. if no value given, there is a default one in code.
It's the same for file selection. the description is used for text link and title for title attribute.
Is it good like that ?

Re: Control of Scaled Down Images Sizes - Listing

Posté : sam. 1 mai 2010 22:43
par Woof
Excellent!
Maybe, for the "néophytes", just above the width height, I would add "Listing size" or Thumbnails size or Vignette size... which ever you would like.
But this is exactly what I was hoping. I hope the Title and Alt value will also be carried over to the Item views :-)

Bravo and well done!

Re: Control of Scaled Down Images Sizes - Listing

Posté : dim. 2 mai 2010 18:25
par steevo
Woof a écrit :I hope the Title and Alt value will also be carried over to the Item views :-)
Of course it will. ;)