?
avatar kurtroesand
kurtroesand
1 Mar 2019

I upgraded to Joomla 3.9.3 the other day, and I noticed a strange behavior for responsive images.

Steps to reproduce the issue

Load an article that have an image in it. Notice that there is a 'float' and 'width' tag inside the HTML. Where the 'width' has been set according to screens size.

Resize window an refresh browser and a new width has been set.

This breaks responsive images, and it looks terrible.

image

Expected result

I'd expect responsive images. As it wore prior to version 3.9.3

Actual result

Breaks responsive images.

System information (as much as possible)

Joomla 3.9.3

Additional comments

avatar kurtroesand kurtroesand - open - 1 Mar 2019
avatar joomla-cms-bot joomla-cms-bot - change - 1 Mar 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 1 Mar 2019
avatar kurtroesand kurtroesand - change - 1 Mar 2019
The description was changed
avatar kurtroesand kurtroesand - edited - 1 Mar 2019
avatar kurtroesand kurtroesand - change - 1 Mar 2019
The description was changed
avatar kurtroesand kurtroesand - edited - 1 Mar 2019
avatar kurtroesand kurtroesand - change - 1 Mar 2019
The description was changed
avatar kurtroesand kurtroesand - edited - 1 Mar 2019
avatar ReLater
ReLater - comment - 2 Mar 2019

Load an article that have an image in it.

Could you please describe the steps where (editor, introimage, fullimage) and how you inserted the image.

avatar SharkyKZ
SharkyKZ - comment - 2 Mar 2019

What you describe is expected behavior and the code responsible for it hasn't been touched for years. See https://github.com/joomla/joomla-cms/blob/staging/media/system/js/caption-uncompressed.js. It could certainly be improved though. Although JCaption is going away in 4.0 anyways.

avatar kurtroesand
kurtroesand - comment - 2 Mar 2019

Load an article that have an image in it.

Could you please describe the steps where (editor, introimage, fullimage) and how you inserted the image.

The images are inserted using 'Images and links'.

avatar kurtroesand
kurtroesand - comment - 2 Mar 2019

What you describe is expected behavior and the code responsible for it hasn't been touched for years. See https://github.com/joomla/joomla-cms/blob/staging/media/system/js/caption-uncompressed.js. It could certainly be improved though. Although JCaption is going away in 4.0 anyways.

Ok, I understand, but the reality is that Joomla 3.9.3 started to break responsive images.

I run a news site that has been working flawlessly for almost two years now, but after upgrading to 3.9.3 images started to not be responsive any longer.

Check this page as an example. (https://ksu.no/artikler/ksu-no/95930-skattebetalere-meldte-seg-med-6-milliarder-i-glemte-formuer) – resize the browser window and you'll see that other elements on the page overlap the image because it does not scale.

Then try this.

  • Right-click the image and select 'Inspect'.
  • Select the div above the img tag
  • Disable 'width' setting (see screenshot)
  • With dev tool open and width disabled you will get normal behavior eg. responsive images.

annotation 2019-03-02 192738

avatar ReLater
ReLater - comment - 2 Mar 2019

I just know that I never used JCaption for image captions but overrides with figure and figcaption HTML. I never used it because of the issue you describe above. Doesn't react dynamically on windows resize. Thus I think SkarkyKZ is right.

avatar HLeithner
HLeithner - comment - 2 Mar 2019

The code adding the width didn't changed in the last years. So the version before should behave exactly the same, except someone modified the core.

You may can fix your problem by add

.img_caption {
  max-width: 100%
}

to your css file in your template.

avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Mar 2019
Status New Information Required
avatar kurtroesand
kurtroesand - comment - 4 Mar 2019

I just know that I never used JCaption for image captions but overrides with figure and figcaption HTML. I never used it because of the issue you describe above. Doesn't react dynamically on windows resize. Thus I think SkarkyKZ is right.

Sounds like this should be modified in the core then. Why use technology that obviously have been broken for years.

avatar ReLater
ReLater - comment - 4 Mar 2019

The images are inserted using 'Images and links'.

I recommend to use JLayout - Overrides for full_image and introimage similiar like Joomla4 does it (figure and figcaption):
https://github.com/joomla/joomla-cms/blob/4.0.0-alpha6/layouts/joomla/content/full_image.php
https://github.com/joomla/joomla-cms/blob/4.0.0-alpha6/layouts/joomla/content/intro_image.php

Then you have full control via CSS.

Why use technology that obviously have been broken for years.

Provide a pr or you have to wait for a volunteer.

avatar SharkyKZ
SharkyKZ - comment - 4 Mar 2019

Sounds like this should be modified in the core then. Why use technology that obviously have been broken for years.

As explained before, this is expected behavior. Nothing is broken. Why wasn't it working as expected on your site until 3.9.3 update is a different question.

You can override this by placing a modified caption.js script in your template's js/system/ directory.

avatar kurtroesand
kurtroesand - comment - 4 Mar 2019

As explained before, this is expected behavior. Nothing is broken. Why wasn't it working as expected on your site until 3.9.3 update is a different question.

Well, "broken". A car could have square wheels – technically it is not broken, but it'll give you one hell of a bumpy ride. :)

You can override this by placing a modified caption.js script in your template's js/system/ directory.

I'm really not a programmer, and I should not try to even think I could fix this.

avatar kurtroesand kurtroesand - change - 4 Mar 2019
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2019-03-04 18:18:39
Closed_By kurtroesand
avatar kurtroesand kurtroesand - close - 4 Mar 2019
avatar SharkyKZ
SharkyKZ - comment - 4 Mar 2019

Yes, it's somewhat outdated but changing it would break expected styling on existing sites. Some would consider this B/C break, in which case it should be done in 4.0. And it is already accomplished by removing the script completely.

I'm really not a programmer, and I should not try to even think I could fix this.

This can be done by removing two lines from source script (caption-uncompressed.js) containing the word "width" and saving the script to js/system/caption.js file in your template's directory. Here's the minified version in case you want to use it on your site:

var JCaption=function(_selector){var $,selector,initialize=function(_selector){$=jQuery.noConflict();selector=_selector;$(selector).each(function(index,el){createCaption(el)})},createCaption=function(element){var $el=$(element),caption=$el.attr('title'),align=$el.attr("align")||$el.css("float")||element.style.styleFloat||"none",$p=$('<p/>',{"text":caption,"class":selector.replace('.','_')}),$container=$('<div/>',{"class":selector.replace('.','_')+" "+align,"css":{"float":align}});$el.before($container);$container.append($el);if(caption!==""){$container.append($p)}};initialize(_selector)};

avatar Sophist-UK
Sophist-UK - comment - 31 Jan 2020

I just had the same issue and found a workaround - so I am updating this in case it is ever useful to anyone else.

The issue I was having was that the JCaption code is taking the image width and applying it to the <div class="image-caption" style="width: ***px;"> tag without adding any horizontal margin / values. I also suspect that the <div class="image-caption" style="width: ***px;"> should copy the image display attribute which for responsive pages is likely to be display="inline-block" as without this the div will be display="block" which won't be responsive.

I had already wrapped my img tag in an <a style="display: inline-block;"> tag, so all I needed to do was to override the width style with css. The CSS I think you therefore need is as follows:

.img_caption {
    display: inline-block;
    width: auto !important;
}

Add a Comment

Login with GitHub to post a comment