[TxMt] Snippet help: get image size?
Allan Odgaard
throw-away-1 at macromates.com
Fri Apr 7 17:19:00 UTC 2006
On 7/4/2006, at 19:05, Timothy Bates wrote:
> With a selection of "x.jpg", I'd like a snippet for the html
> context that
> can insert
>
> <img src="x.jpg" alt=" x.jpg" width="164" height="234" border="0"
> class="box1">
In the HTML bundle there is a drag command which is named “Insert
Image With Dimensions”.
This does it, but for dropped images. You can create a new command
(which has input set to none, and output set to discard), then copy
the code from the drag command, but change the first line to:
img="${TM_SELECTED_TEXT}"
It may need a few more tweaks, but it basically does 99% of what you
need. It also constructs the alt-text from the image name.
> PS: if you find yourself making lists out of lines of text, this
> helps me
>
> <${1:ol}>
> ${TM_SELECTED_TEXT/(^.+$)/\t<li>$1<\/li>/g}
> </$1>
On a related note, in addition to the Wrap Selection in Open/Close
Tag (on ctrl-shift W) there is also Wrap Each Selected Line in Open/
Close Tag (on ctrl-shift-cmd W).
More information about the textmate
mailing list