Skip to main content
GabrielCameron
Participating Frequently
November 15, 2021
Answered

Replacing Image Automatically Resizes CSS Width Property

  • November 15, 2021
  • 1 reply
  • 1637 views

We work on a lot of templated emails that require swapping out some old images for new images.

 

Existing image is set with inline CSS to have a width of 600px.

 

When I replace that image with a new image it automatically updates the CSS width property to whatever the width of the new image is, for instance 1200px.

 

I don't want the width to update automatically. How do I change this default setting?

    This topic has been closed for replies.
    Correct answer B i r n o u

    Thanks for the resources, and for taking the time to respond. But I know how to optimize images.

     

    What I'm asking for is a way to change Dreamweaver's default setting when you use the Properties panel to browse and replace an image source. By default Dreamweaver automatically changes the CSS width property to whatever the width of the new image is. I want to change the default setting so that it doesn't change the width property.

     

    If you know how to do this, that would be really helpful.


    quote

    What I'm asking for is a way to change Dreamweaver's default setting when you use the Properties panel to browse and replace an image source. By default Dreamweaver automatically changes the CSS width property to whatever the width of the new image is. I want to change the default setting so that it doesn't change the width property.

     

    If you know how to do this, that would be really helpful.


    By @GabrielCameron

     

    @GabrielCameron in fact you don't have a direct way to do that... but the workaround, is to manually remove the WIDTH and HEIGHT attributes fomr the HTML code, and add an online CSS style to handle width and height as you like.

    then when you swap images from the SRC attribute, the WIDTH and HEIGHT attributes wont recreate themselves.

    so change

    <img src="image-A.jpg" width="400" height="400" alt=""/>

    to

    <img src="image-A.jpg" style="width:400px;height:400px;" alt=""/>

    so when you will change to a different image (from SRC attribute that should stay as

    <img src="image-B.jpg" style="width:400px;height:400px;" alt=""/>

     

    1 reply

    Nancy OShea
    Community Expert
    Community Expert
    November 15, 2021

    Of course inline CSS styles will be removed when you replace the HTML image.  That's normal & expected.  Also you're not doing users any favors by sending them oversized image files.  It's too much bandwidth to consume.

     

    All web images must be optimized beforehand in Photoshop (or other graphics editor).  1200 pixels is too big for emails.  Inline CSS doesn't reduce the file size.  It merely re-scales what's there to fit your layout.

     

    Hope that helps.

     

    Nancy O'Shea— Product User & Community Expert
    GabrielCameron
    Participating Frequently
    November 15, 2021

    Hey Nancy, thanks for responding and for the tips on optimization.

     

    I understand about all that, but I've found for my particular use case the images are more crisp when using a 2x image, especially for retina displays. The larger file size is a tradeoff I'm happy to make in this case.

     

    Hoping to find a way to change that default setting to optimize my workflow. 

    Nancy OShea
    Community Expert
    Community Expert
    November 15, 2021

    I see.  Well I suggest you do some homework on optimizing emails for average users.  Follow the recommended BEST PRACTICES from leading email sending services like MailChimp and Constant Contact.  Their business is built on knowing what works best for the majority of users without punishing NON-Retina users.

     

    Good luck!

     

    Nancy O'Shea— Product User & Community Expert