User tests: Successful: 2 davidsteltz, twister65 Unsuccessful: 1 brianteeman
Pull Request for Issue # .
Random Image module.
If Responsive is enabled, the image is automatically resized to fit the position container.
If Responsive is disabled (set to No), we have the previous behavior (without modification).
Create a new Random Image module.
Set path to image folder (images/banners, for example).
Select Position (Banner, for example).
Enable/disable Responsive parameter.
If set to yes, the image/picture is scaled to the window.
Otherwise, the image/picture is static (this depends on the width and height parameters)
As expected.
Category | ⇒ | Language & Strings Modules Front End |
Status | New | ⇒ | Pending |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-23 14:28:51 |
Closed_By | ⇒ | twister65 | |
Labels |
Added:
?
?
|
Status | Closed | ⇒ | New |
Closed_Date | 2017-08-23 14:28:51 | ⇒ | |
Closed_By | twister65 | ⇒ |
Status | New | ⇒ | Pending |
I really don't see the need for this at all.
Bootstrap already applies the following styling to images:
max-width: 100%;
height: auto;
So if no values are defined for the width
and height
parameters, the image is already repsonsive.
Therefore why do we need to add a paremeter for it?
@C-Lodder , see
getRandomImage function :
https://github.com/twister65/joomla-cms/blob/f23cdc3727c847133ae352eb3de9f856e369d79f/modules/mod_random_image/helper.php#L21
Responsive Random Image Module discussion (on forum) :
https://forum.joomla.org/viewtopic.php?t=840822
best is:
max-width: 'real_image_width' px;
max-height: 'real_image_height' px;
otherwise small images will get stretched and look ugly
IMO there really doesn't need to be a parameter. Just remove all the stupid code in the helper.php and use the necessary CSS.
Images should by default, be responsive unless stated otherwise.
helper.php
public static function getRandomImage(&$params, $images)
{
$width = $params->get('width') !== null ? $params->get('width') : '';
$height = $params->get('height') !== null ? $params->get('height') : '';
$i = count($images);
$random = mt_rand(0, $i - 1);
$image = $images[$random];
$image->width = $width;
$image->height = $height;
$image->folder = str_replace('\\', '/', $image->folder);
return $image;
}
CSS:
img {
display: block;
width: 100%;
height: auto;
}
done
I have tested this item
tested with protostar in position 8 and position 7
Cause you need to set the width
, not just max-width
@brianteeman , to test you need these commits :
@twister65 We don't test single commits, we always test the complete PR.
I applied the PR
Cleared the caches
Then setup the module as described above
I have tested this item
Patch applied with the latest version of joomla-cms-staging and Pull ID #17688.
@twister65 testing own PR doesn't count cause its expected that a PR is tested by Dev.
I have tested this item
Without responsive:
With responsive:
I agree with others that this should be default behavior rather than a parameter.
It may be useful to choose, when you want to display random images as thumbnails (with link).
True, perhaps the toggle should be Full Width vs. Thumbnail instead of Responsive vs. Static?
The size is adjusted according to your device (responsive), or not (static).
Please don't add more options. The easiest way to achieve this or anything similar is:
No need for view overrides at all.
Can be done completely just using the current parameters and a CSS/PHP tweak
Disregarding any successful tests, this is just wrong. The code, the method, even the referenced discussion is almost three and a half years old.
@matrikular - so explain what you'd do then
I agree with @matrikular here. The discussion should be on images srcset if we are talking about responsive, adaptive whatever you wanna call it
@dgt41 - That would require the media manager to generate separate image files when uploading. But doesn't solve the actual issue here
If your largest image of the srcset
is 1200px, you're using a fluid container, and your viewport is 1920px, it won't be 100$ width unless specified in the CSS
@C-Lodder I'm not sure what you're asking for exactly. You yourself gave some valid answers / examples to that question.
<bla>
There are many different techniques, approaches and caveats to the topic of responsible and / or adaptive images that need to be thoroughly thought through and addressed for the whole site and not seldom, treated differently for different parts and / or content types within a site.
I believe that we can all agree on the fact that changing some inline style attributes for "one" image in "one" module does not accomplish much. The rendered markup, whereever it comes from (CMS / Framework), should be as generic as possible, allowing the site owner / template developer to implement any solution he / she sees fit.
Since the early days, we make use of class suffixes to customise the output and while we added more and more parameters over the years to allow non-developers to change the look and / or behavior of say modules, there is just so much of what can be accomplished (as in limitation) with this approach.
Personally, I'm questioning the module and its implementation. Be it the entry point, the helper or the output.
</bla>
TL/DR
As to the responsiveness; just make sure that width and height are added as an attribute instead of a style declaration. That way, if no container acts as a placeholder, the browser knows how much space the image will use, preventing any ominous flickering / jumping (not that I would have seen such behavior lately). In doing so, you allow "external" style declarations to "take over".
@matrikular All Im asking for is for this parameter to be removed and images be responsive by default unless specified by the width and height parameter.
By your initial comment, I assumed you may have had a different approach.
Status | Pending | ⇒ | Needs Review |
Closed_Date | 2018-05-23 11:51:46 | ⇒ | 2018-05-23 11:51:47 |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Status | Needs Review | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-05-23 11:51:46 |
Closed_By | ⇒ | Quy |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/17688
Closing for reasons stated above.
Please,only take into consideration the last commit:
cd95648