Skip to main content
Topic: Attachment images not responsive (Read 1639 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Attachment images not responsive

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)


Re: Attachment images not responsive

Reply #1
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:-)
Bugs creator.
Features destroyer.
Template killer.

Re: Attachment images not responsive

Reply #2
@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 :/ 
Be safe, Be kind, Happy Programing

Re: Attachment images not responsive

Reply #3
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.
Master of Expletives: Now with improved family f@&king friendliness! :D

Sources code: making easy front end changes difficult since 1873. :P