Hi
Well it's a tiny thing, but it is there since Mambo: On the left of "Width" and "Height" in module "Random Image" it says "(px)", which is not true. It is possible to use any size specification allowed.
In our case, we have a folder with images of different size and don't want them to be resized, so I used "100%" for width and height. This way we don't have to patch the module-file after every update :P
Thanks & greets
[KNOWN ISSUE] Please remove "(px)" from Width and Height in module "Random Image"
-
- Joomla! Fledgling
- Posts: 3
- Joined: Thu Jun 22, 2006 1:14 pm
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
Re: Please remove "(px)" from Width and Height in module "Random Image"
Looking at the code, it should be px because IF you only specify 1 dimension e.g. width (which is very useful if you wish a range of differently proportioned images to fit within a fixed width) the code will calaculate the other dimension to maintain the correct aspect:
this is done using getimagesize() function which returns values in px (although the issue is really that the width you supply gets divided by the coeff, which is not going to work correctly if you have supplied anything other than a plain number )
if you specify both dimensions, then the dimensions just get used in the img html width and height so in that case it does not matter.
I suppose you could explain this in the module, but it may confuse as many people as it helps
Code: Select all
$size = getimagesize ($abspath_image);
if ($width == '') {
($size[0] > 100 ? $width = 100 : $width = $size[0]);
}
if ($height == '') {
$coeff = $size[0]/$size[1];
$height = (int) ($width/$coeff);
}
if you specify both dimensions, then the dimensions just get used in the img html width and height so in that case it does not matter.
I suppose you could explain this in the module, but it may confuse as many people as it helps
Last edited by toubkal on Thu Jun 22, 2006 2:45 pm, edited 1 time in total.
Do you want the answer to be as vague as your question?
-
- Joomla! Fledgling
- Posts: 3
- Joined: Thu Jun 22, 2006 1:14 pm
Re: Please remove "(px)" from Width and Height in module "Random Image"
Well, it auto-calculates only the height, so I would propose the following:
But the real problem is this: There's no note about a default value if the fields are left empty. So my assumption (and probably that of many users) was that if I don't specify anything, it doesn't resize anything. If the pictures are resized to a hardcoded value, it has to be at least documented. But anyway, hardcoding magic numbers is bad coding style.
So I would change code to:
... and than add a note like: "You can also specify the size in percent but make sure you specify both width and height"
This way you probably have 99 percent of all use cases covered.
A much nicer implementation would be to use/code a generic image-manipulation/parameters-component which could be used everywhere you can include an image.
Code: Select all
if ($width == '') {
if ($height == '') {
$coeff = $size[0]/$size[1];
$width = (int) ($height*$coeff);
else {
($size[0] > 100 ? $width = 100 : $width = $size[0]);
}
}
if ($height == '') {
$coeff = $size[0]/$size[1];
$height = (int) ($width/$coeff);
}
So I would change code to:
Code: Select all
if ($width == '') {
$width = $size[0];
if ($height != '') {
$coeff = $size[0]/$size[1];
$width = (int) ($height*$coeff);
}
}
if ($height == '') {
$coeff = $size[0]/$size[1];
$height = (int) ($width/$coeff);
}
This way you probably have 99 percent of all use cases covered.
A much nicer implementation would be to use/code a generic image-manipulation/parameters-component which could be used everywhere you can include an image.
- toubkal
- Joomla! Hero
- Posts: 2860
- Joined: Thu Aug 18, 2005 4:35 pm
- Location: Cheshire, England
- Contact:
Re: Please remove "(px)" from Width and Height in module "Random Image"
Code: Select all
if ($width == '') {
($size[0] > 100 ? $width = 100 : $width = $size[0]);
Do you want the answer to be as vague as your question?
-
- Joomla! Fledgling
- Posts: 3
- Joined: Thu Jun 22, 2006 1:14 pm
Re: Please remove "(px)" from Width and Height in module "Random Image"
Well, that's exactly the thing I think it shouldn't do. I mean, what sense does it make?
- RobS
- Joomla! Ace
- Posts: 1366
- Joined: Mon Dec 05, 2005 10:17 am
- Location: New Orleans, LA, USA
- Contact:
Re: Please remove "(px)" from Width and Height in module "Random Image"
Moving to known issues. This is a feature request and will not be addressed in the 1.0.x branch.
Rob Schley - Open Source Matters
Webimagery - http://www.webimagery.net/ - Professional Consulting Services
JXtended - http://www.jxtended.com/ - Free and Commercial Joomla! Extensions
Webimagery - http://www.webimagery.net/ - Professional Consulting Services
JXtended - http://www.jxtended.com/ - Free and Commercial Joomla! Extensions