Hello,
Early on the first day of this mailing list I sent an email about my first impressions, both positive and negative, which generated a few responses, including one from Allen I believe. That said I want to highlight what for me, as an HTML coder, is the only major downfall that has not been spoken about extensively:
Dragging an image from the project pane into a HTML file should add something like <img src="eric.jpg" alt="eric" width="100" height="100" /> and not the actual source code of an image at the insertion point.
Now I have seen a few requests that suggest highlighting an image in the project drawer should display the graphic file instead of the code and I agree, however this is not the major hurdle in my book. We need to be able to grab a file from the drawer and pull it into our html code and have the correct width and height added automatically.
I have been letting this subject percolate for a few days in my head and I just can not think of another workaround that would approach any reasonable level of efficiency (I would love to hear some though). I could make a macro and have it tab stop at the name, width, height and alt however I am not going to know the width and height in 99% of the cases. I personally would also like to have it automatically add the file name without the extension as the alt tag though some might argue that this will promote poor coding practices, I tend to label my files with readable names...
Please take care of this ASAP...
Sincerely,
Eric Curtis
On Oct 11, 2004, at 2:18 PM, Eric Curtis wrote:
Hello,
Early on the first day of this mailing list I sent an email about my first impressions, both positive and negative, which generated a few responses, including one from Allen I believe. That said I want to highlight what for me, as an HTML coder, is the only major downfall that has not been spoken about extensively:
Dragging an image from the project pane into a HTML file should add something like <img src="eric.jpg" alt="eric" width="100" height="100" /> and not the actual source code of an image at the insertion point.
Eric -- I would love to see this as well. Now that the wiki is up, perhaps we should start an HTML/CSS feature request page?
On 12/10/2004, at 10:18 AM, Eric Curtis wrote:
I have been letting this subject percolate for a few days in my head and I just can not think of another workaround that would approach any reasonable level of efficiency (I would love to hear some though). I could make a macro and have it tab stop at the name, width, height and alt however I am not going to know the width and height in 99% of the cases. I personally would also like to have it automatically add the file name without the extension as the alt tag though some might argue that this will promote poor coding practices, I tend to label my files with readable names...
Please take care of this ASAP...
I don't think this can be taken care of with Macros or existing commands, so it might have to be "hard coded" into TM, which will take longer... it's on my personal to-do/mission list http://wiki.macromates.com/textmate/show/JustinFrenchToDo, and I'm emailing Allan some ideas right now...
In the meantime, may I suggest the following:
- use the img snippet (type img[tab]) which excludes height and width - modify the img snippet so that it has a place holder where height & width should be - use Finder and the "Dimensionizer" contextual menu plug-in [1] to get the height and width string for you, paste into TM
It isn't pretty, but it's a temporary workflow that works for me.
Then again, most of the time I use PHP to grab my images on the fly... instead of: <img src="eric.jpg" alt="eric" width="100" height="100" /> I'd have: <?=imageTag('eric.jpg','Photo of Eric')?>
imageTag() checks for a valid image and location (no more broken image links), determines the height and width, and if the 2nd attribute isn't given (alt text), it will "make up" an alt tag based on the filename (eg "Eric"), then generates the tag.
I can't remember the last time I wrote an image tag actually! I think I'll write up this imageTag() function of mine on my blog [2] in the next few days, so any one who's interested, keep an eye out.
[1] http://automaticlabs.com/products/dimensionizer/ [2] http://justinfrench.com
Justin French
On Oct 11, 2004, at 6:50 PM, Justin French wrote:
On 12/10/2004, at 10:18 AM, Eric Curtis wrote:
I have been letting this subject percolate for a few days in my head and I just can not think of another workaround that would approach any reasonable level of efficiency (I would love to hear some though). I could make a macro and have it tab stop at the name, width, height and alt however I am not going to know the width and height in 99% of the cases. I personally would also like to have it automatically add the file name without the extension as the alt tag though some might argue that this will promote poor coding practices, I tend to label my files with readable names...
Please take care of this ASAP...
I don't think this can be taken care of with Macros or existing commands, so it might have to be "hard coded" into TM, which will take longer... it's on my personal to-do/mission list http://wiki.macromates.com/textmate/show/JustinFrenchToDo, and I'm emailing Allan some ideas right now...
On Oct 11, 2004, at 6:50 PM, Justin French wrote:
On 12/10/2004, at 10:18 AM, Eric Curtis wrote:
I have been letting this subject percolate for a few days in my head and I just can not think of another workaround that would approach any reasonable level of efficiency (I would love to hear some though). I could make a macro and have it tab stop at the name, width, height and alt however I am not going to know the width and height in 99% of the cases. I personally would also like to have it automatically add the file name without the extension as the alt tag though some might argue that this will promote poor coding practices, I tend to label my files with readable names...
Please take care of this ASAP...
I don't think this can be taken care of with Macros or existing commands, so it might have to be "hard coded" into TM, which will take longer... it's on my personal to-do/mission list http://wiki.macromates.com/textmate/show/JustinFrenchToDo, and I'm emailing Allan some ideas right now...
What would be nice is a per-language drag hook. For example, for shell scripts, I'd like to have the raw path of a file or folder, rather than the file content or directory listing. For XML, I might want a relative XPath, calculated from project root.
(And then, of course, we need a $TM_MODIFIER_KEYS variable to allow modification of drop behavior...)
Chris
On 12/10/2004, at 1:28 PM, Chris Thomas wrote:
What would be nice is a per-language drag hook. For example, for shell scripts, I'd like to have the raw path of a file or folder, rather than the file content or directory listing. For XML, I might want a relative XPath, calculated from project root.
(And then, of course, we need a $TM_MODIFIER_KEYS variable to allow modification of drop behavior...)
That's exactly the same thoughts/ideas I sent to Allan :)
Justin French
On Oct 11, 2004, at 5:58 PM, Justin French wrote:
On 12/10/2004, at 1:28 PM, Chris Thomas wrote:
What would be nice is a per-language drag hook. For example, for shell scripts, I'd like to have the raw path of a file or folder, rather than the file content or directory listing. For XML, I might want a relative XPath, calculated from project root.
(And then, of course, we need a $TM_MODIFIER_KEYS variable to allow modification of drop behavior...)
That's exactly the same thoughts/ideas I sent to Allan :)
Ooh, even better, So there could be a Ruby language hook that works like the PHP one you explained earlier Justin?
On 12. Oct 2004, at 5:28, Chris Thomas wrote:
What would be nice is a per-language drag hook. For example, for shell scripts, I'd like to have the raw path of a file or folder, rather than the file content or directory listing. For XML, I might want a relative XPath, calculated from project root.
Yes, something like this is what I'd prefer. I'm not going to hardcode HTML-support into TextMate in a way that makes it do image markup. But I _would_ like to make a general system that allows HTML users to achieve the same (and we'll just put this in the default HTML.tmbundle).
(And then, of course, we need a $TM_MODIFIER_KEYS variable to allow modification of drop behavior...)
Ah, nice touch!
Kind regards Allan
On 12. Oct 2004, at 2:18, Eric Curtis wrote:
I could make a macro and have it tab stop at the name, width, height and alt however I am not going to know the width and height in 99% of the cases. [...]
You can call out to an external command in the macro, to get the dimensions.
Unfortunately the 'file' command (which ships with OS X) only dump image dimensions for a few image types, but PNG and GIF are among these though (JPEG is not AFAIRC).
If you wan't, I can experiment a bit and send a step-by-step explanation on how to make such a macro. I don't know if it's best to start with the filename or the img-tag (and then just insert the width/height)?!?
Kind regards Allan
On Oct 11, 2004, at 6:34 PM, Allan Odgaard wrote:
If you wan't, I can experiment a bit and send a step-by-step explanation on how to make such a macro.
yes
I don't know if it's best to start with the filename or the img-tag (and then just insert the width/height)?!?
not quite sure what you mean Allan
On 12. Oct 2004, at 11:39, Timothy Martens wrote:
If you wan't, I can experiment a bit and send a step-by-step explanation on how to make such a macro.
yes
Okay, select Command / Edit Menu… and press the + sign.
Enter a suiting name and a key equivalent and put this in the command(s): text box (leave the other things as their defaults): ----------8<---------- cd "$TM_DIRECTORY" image=$TM_SELECTED_TEXT
# check if image exists on disk [ -f $image ] || { echo $image; exit 1; }
# extract width, height and alt-text w=`file "$image" | perl -pe 's/^.*,\s*(\d+)[ x]+(\d+)\s*(,.*|$)/$1/'` h=`file "$image" | perl -pe 's/^.*,\s*(\d+)[ x]+(\d+)\s*(,.*|$)/$1/'` alt=`echo $image | perl -pe 's/^(.*/)?(.*?)(..*)?$/$2/g'`
# write the img tag to stdout echo "<img src="$image" width="$w" height="$h" alt="$alt" />" ---------->8----------
With this command I can write: "images/apache_pb.gif", select it, and execute the above command, and it turns into: "<img src="images/apache_pb.gif" width="259" height="259" alt="apache_pb" />"
Of course it'll be easier when we add the drag hooks, and it'll be better when 'insert as snippet' becomes an output option (since you can then have the alt-text selected, and another placeholder after the image or similar).
And as said, the 'file' command can only give image dimensions for PNG and GIF pictures. It may be possible to query apple script actually, but startup time for AS is poor IMHO.
I'll figure out a solution when I do the drag hooks, so that we can ship with a default drag hook for images that just works... :)
I don't know if it's best to start with the filename or the img-tag (and then just insert the width/height)?!?
not quite sure what you mean Allan
Well, either you could be interested in inserting width/height to an existing image tag, or you could want TM to create the img-tag from the file name.
I made the above command expect the latter.
Kind regards Allan
On 12 oct. 2004, at 14:00, Allan Odgaard wrote:
And as said, the 'file' command can only give image dimensions for PNG and GIF pictures. It may be possible to query apple script actually, but startup time for AS is poor IMHO.
Use SIPS then. SIPS [1] is the "Scriptable Image Processing Server" and can be accessed through AppleScript AND the 'sips' command line tool.
For example, to query an image for its width and height, just do: sips -g pixelWidth -g pixelHeight the_image
To get help: sips -h
To know all available properties: sips -H
Note: I think that SIPS is only available on 10.3.
[1] http://www.apple.com/applescript/imageevents/