Is there any way in TM to insert an image into my HTML doc sort of the way Dreamweaver does it? I'd like to be able to click a shortcut, the finder window pops-up so I can choose the file, the image tag gets inserted with the correct filename and height/width attributes. Any way to do this?
Thanks!
Sean
:::: DataFly.Net :::: Complete Web Services http://www.datafly.net
On May 19, 2006, at 8:50 PM, Sean Schertell wrote:
Is there any way in TM to insert an image into my HTML doc sort of the way Dreamweaver does it? I'd like to be able to click a shortcut, the finder window pops-up so I can choose the file, the image tag gets inserted with the correct filename and height/width attributes. Any way to do this?
Thanks! Sean
You should be able to just drag the image where you want the tag. If you're in HTML it'll create the link for you with height & width. There's no open dialog for it, you have to drag is from the finder or Quicksilver or command drag it from the dock, etc...
thomas Aylott—subtleGradient—oblivious@subtleGradient.com
I typically drag 'em from the drawer. Just the other day I made a handful of variants for CSS and Rails. TM was rockin' my world that day.
Corey
On May 19, 2006, at 10:42 PM, thomas Aylott wrote:
On May 19, 2006, at 8:50 PM, Sean Schertell wrote:
Is there any way in TM to insert an image into my HTML doc sort of the way Dreamweaver does it? I'd like to be able to click a shortcut, the finder window pops-up so I can choose the file, the image tag gets inserted with the correct filename and height/width attributes. Any way to do this?
Thanks! Sean
You should be able to just drag the image where you want the tag. If you're in HTML it'll create the link for you with height & width. There's no open dialog for it, you have to drag is from the finder or Quicksilver or command drag it from the dock, etc...
thomas Aylott—subtleGradient—oblivious@subtleGradient.com
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On May 19, 2006, at 8:50 PM, Sean Schertell wrote:
Is there any way in TM to insert an image into my HTML doc sort of the way Dreamweaver does it? I'd like to be able to click a shortcut, the finder window pops-up so I can choose the file, the image tag gets inserted with the correct filename and height/width attributes. Any way to do this?
Thanks! Sean
You should be able to just drag the image where you want the tag. If you're in HTML it'll create the link for you with height & width. There's no open dialog for it, you have to drag is from the finder or Quicksilver or command drag it from the dock, etc...
Hmm... that's a bit of a disappointment that the only way to get auto height/width is with the mouse. Is it possible to add this functionality with a command? Any plans to add this functionality to TM in the future?
Cheers, Sean
:::: DataFly.Net :::: Complete Web Services http://www.datafly.net
On 22/5/2006, at 4:53, Sean Schertell wrote:
Hmm... that's a bit of a disappointment that the only way to get auto height/width is with the mouse. Is it possible to add this functionality with a command?
Sure it is -- it is already done with a drag command, you just need to make it a regular command that e.g. uses AS to prompt for the filename.
Here’s a quick proof-of-concept, set input: none, output: insert as snippet:
img=$(osascript -e 'tell app "SystemUIServer"' -e activate -e 'return POSIX path of (choose file with prompt "Pick an image:")' -e 'end tell')
err=$? osascript -e 'tell app "TextMate" to activate' &>/dev/null &
[[ $err == 0 ]] || exit_discard
src=${img#$(dirname "${TM_FILEPATH:-}")/} echo -n "<img src="$src" "
sips -g pixelWidth -g pixelHeight "$img" \ |awk '/pixelWidth/ { printf("width="%d" ", $2) } /pixelHeight/ { printf("height="%d" ", $2) }'
base=${img##*/} alt=$(tr <<<${base%.*} '[_-]' ' '|perl -pe 's/(\w+)/\u$1/g') echo -n "alt="${1:$alt}" />"
Or starting with next (cutting edge) build, just click this file:
Wow -- thanks for that Allan! So am I to understand then that the next version of TM is going have such a feature built-in?
Sean
On May 22, 2006, at 12:35 PM, Allan Odgaard wrote:
On 22/5/2006, at 4:53, Sean Schertell wrote:
Hmm... that's a bit of a disappointment that the only way to get auto height/width is with the mouse. Is it possible to add this functionality with a command?
Sure it is -- it is already done with a drag command, you just need to make it a regular command that e.g. uses AS to prompt for the filename.
Here’s a quick proof-of-concept, set input: none, output: insert as snippet:
img=$(osascript -e 'tell app "SystemUIServer"' -e activate -e 'return POSIX path of (choose file with prompt "Pick an image:")' - e 'end tell')
err=$? osascript -e 'tell app "TextMate" to activate' &>/dev/null &
[[ $err == 0 ]] || exit_discard
src=${img#$(dirname "${TM_FILEPATH:-}")/} echo -n "<img src="$src" "
sips -g pixelWidth -g pixelHeight "$img" \ |awk '/pixelWidth/ { printf("width="%d" ", $2) } /pixelHeight/ { printf("height="%d" ", $2) }'
base=${img##*/} alt=$(tr <<<${base%.*} '[_-]' ' '|perl -pe 's/(\w+)/\u$1/g') echo -n "alt="${1:$alt}" />"
Or starting with next (cutting edge) build, just click this file:
<Insert Image.tmCommand>
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
:::: DataFly.Net :::: Complete Web Services http://www.datafly.net
Sean Schertell wrote:
Wow -- thanks for that Allan! So am I to understand then that the next version of TM is going have such a feature built-in?
No, he's saying that the next build (now the current cutting-edge build) will have support for just opening a .tmCommand file, and having the command copied into TextMate.