Last Updated: October 25, 2016

Image Tag Dimension Completion

Macro Monday – a new macro to dig into every Monday!

Quickly add image dimensions to an `` tag based off the image tags src
attribute. Everyone wants it, now you’ve got it.

## The Things I Need

How often have you entered an image tags src attribute and thought “GO!… Fill it
in… Please..”? I know I have. At least twice.

Others have had similar thoughts and one such user [requested this of Komodo](
some time ago. EricP answered the call and gave the user something that worked.

It uses the [Image() object](
in Javascript that allows us to load the image then pulls some information
from it and use it to append *height* and *width* attributes to the image tag
you’re working in.

I’ve updated it to use the *load* event to be sure the image is ready when I pull
properties off of it. I’ve also created a full path for the image which
[ToddW]( says will bite me in the @$$ later but only time will tell.

## Installation

To install the macro simply hit the “View Resource” button below, for instructions
on how to install it refer to the [Install Resources Documentation](

View Resource

## Usage

To use the macro, make an editor selection and then invoke the macro – by
double-clicking on the macro in the toolbox, using the Invoke Tool
(Ctrl+Shift+K) to search/execute “img tag dimensions”, or assigning your own
keybinding to the macro. Click on the link below and have a look at the source
for yourself.

Carey Hoffman

Carey Hoffman

Carey made the logical switch from snowboard instructing and treeplanting to the technology industry in 2009, taking database and network administration at Vancouver BC's BCIT college. Having started out on the technical support and QA team for ActiveState he now works on the Komodo development team as a front and backend software engineer.