Learn More





Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Responsive Images in HTML ModuleResponsive Images in HTML Module
New Post
2/21/2014 2:43 AM

I have an image inside an html module and I want it to automatically resize for mobile/tablets. The image size is 600px x 216px and looks ok on my desktop but it is way too big for mobile/tablets. I found the following javascript code and inserted it into the page header metatags -


$(document).ready(function() {

     // Set the variable $width to the width of our wrapper on page load

     $width = $('#content').width();

     // Target all images inside the #content. This works best if you want to ignore certain images that are part of the layout design

     $('#content img').css({

          // Using jQuery CSS we write the $width variable we previously specified as a pixel value. We use max-width incase the image is smaller than our viewport it won't scale it larger. Don't forget to set height to auto or else it will squish your photos.

          'max-width' : $width , 'height' : 'auto'




Then I used the following within the html module -

<div id="content"><img alt="" src="/portals/3/logo.jpg" /></div></div>  

It works ok but I am wondering if this is the best way to do it or should I be doing it in the page skin?


New Post
2/21/2014 3:03 AM
if the image is part of your content, using HTML module is appropriate.

Cheers from Germany,
Sebastian Leupold (Microsoft MVP)

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group   European Network of DotNetNuke Professionals

Speed up your DNN Websites with TurboDNN
New Post
2/21/2014 3:15 AM

And the code I posted is the correct way to resize the image??


New Post
2/21/2014 4:16 AM

IMO it's not the best way to do this.

I would use CSS for this, not JS and add that to your skin.css or portals.css


 As there is normally no real reason why an image should be bigger than it's containing element, you can set this for all images

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Responsive Images in HTML ModuleResponsive Images in HTML Module

These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?