ElkArte Community

Elk Development => Bug Reports => Topic started by: badmonkey on June 21, 2016, 09:10:50 pm

Title: Attachment images not responsive
Post by: badmonkey on June 21, 2016, 09:10:50 pm
Not sure about 1.1.  This applies to 1.0.  Attachment images overflow using stock code.  Not to worry, there is a proposed solution.   :)

Adding img styling to custom.css makes the image fit the width but image proportions are lost.  Huh?  Oh yeah, there is a hard coded style tag.  In /themes/default/Display.template.php, on line 864 find:

Code: [Select]
<img src="' . $attachment['href'] . ';image" alt="" style="width:' . $attachment['width'] . 'px; height:' . $attachment['height'] . 'px;"/>';

and replace with:

Code: [Select]
<img src="' . $attachment['href'] . ';image" alt="" />';

Finally, drop this into custom.css:

Code: [Select]
img
{
max-width: 95%;
height: auto;
}

Now it all works.  At least it's a hack.  Perhaps real devs could review this solution?  Or create a better one?  Thanks for watching!   8)

Title: Re: Attachment images not responsive
Post by: emanuele on June 22, 2016, 02:54:19 am
I feel I reported something similar a while ago... or it was just that attachments were going nuts? Dunno.
Either way... I guess that if it works we can consider for the upcoming 1.0.8. O:-)
Title: Re: Attachment images not responsive
Post by: Spuds on June 22, 2016, 07:20:18 am
@Antechinus provided some updated code for the attachment area a week or two back.  I have not had a chance to try it out since I'm traveling.  I think the width and height are used by JS to do the 1.0.x expand / collapse of images (if enabled), not sure about that though :/ 
Title: Re: Attachment images not responsive
Post by: Antechinus on June 22, 2016, 05:58:10 pm
Yeah they are, but max-width and max-height in the CSS will override the inline width and height, so it'll still only expand to post width.