Home Download Buy Blog Forum Support

Plugin to hlep with img tags in HTML

Plugin to hlep with img tags in HTML

Postby alexrussell on Wed Apr 25, 2012 9:05 am

I've just converted a designer from Dreamweaver to ST2 (my plan is to have everyone in the office on ST2) and after seeing the autocomplete for CSS and HTML on my computer he felt he was prepared to switch over. However, he's just realised that ST2 doesn't have the convenient <img> functionality that Dreamweaver did. In case you don't know, Dreamweaver will autocomplete the 'src' attribute from the current file path, and also on confirmation of the autocomplete with fill in the 'width' and 'height' attributes too.

Presumably, making a plugin to produce an autocomplete dropdown for src=" trigger (maybe there's even a scope for this, but doubtful) wouldn't be too difficult for a decent plugin writer, and could even use the fuzzy search built into ST2, but what about getting an image's width and height and inserting those into the page on confirmation of the autocomplete? Is this difficult or not possible?

Obviously if anyone fancies writing such a plugin we'd be grateful, but really I just care about how likely it is to be possible right now, and I could maybe have a go at writing my own (although my Python and knowledge of the ST2 API is very limited).
alexrussell
 
Posts: 74
Joined: Fri Jul 15, 2011 9:06 am

Re: Plugin to hlep with img tags in HTML

Postby C0D312 on Wed Apr 25, 2012 11:07 am

My AutoFileName plugin should do the first part. It lets you navigate the file structure to insert a filename. If you give me some time, I try adding the width and height features into the plugin (though I don't know how easy this would be, especially cross-platform).
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Plugin to hlep with img tags in HTML

Postby skube on Wed Apr 25, 2012 2:43 pm

Although the main problem with AutoFileName for me is that it is useless when using absolute paths.
skube
 
Posts: 86
Joined: Tue Feb 28, 2012 8:42 pm

Re: Plugin to hlep with img tags in HTML

Postby C0D312 on Wed Apr 25, 2012 3:23 pm

skube wrote:Although the main problem with AutoFileName for me is that it is useless when using absolute paths.


If you're having a problem with the plugin, could you please file a bug report? There's no way for me to know if people are having issues if no one reports any problems. AutoFileName should work for absolute paths just fine. If it's not working for you could you please give me some more info? Platform? Errors in Console (Control + `)? Sample file you're trying to use it with?

Thanks.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Plugin to hlep with img tags in HTML

Postby skube on Wed Apr 25, 2012 4:27 pm

I'm not sure how to file a bug report, but in any case, it probably isn't a bug. There are no errors in the console.

For my setup, I run a local webserver in which the absolute root of my webserver is not necessarily the root of my computer. AutoFileName seems to pickup the root of my computer and there appears to be no way to override that.

I'm using:
- ST2 2181
- Windows 7
skube
 
Posts: 86
Joined: Tue Feb 28, 2012 8:42 pm

Re: Plugin to hlep with img tags in HTML

Postby C0D312 on Wed Apr 25, 2012 9:55 pm

Oh okay. Now I understand. Someone else already requested this and its on my todo list. I'll get started on it as soon as I get a change. Thanks for the explanation though.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: Plugin to hlep with img tags in HTML

Postby pjv on Wed Apr 25, 2012 11:48 pm

skube wrote:I'm not sure how to file a bug report, but in any case, it probably isn't a bug. There are no errors in the console.

For my setup, I run a local webserver in which the absolute root of my webserver is not necessarily the root of my computer. AutoFileName seems to pickup the root of my computer and there appears to be no way to override that.

I'm using:
- ST2 2181
- Windows 7


C0D312 wrote:Oh okay. Now I understand. Someone else already requested this and its on my todo list. I'll get started on it as soon as I get a change. Thanks for the explanation though.


hi, "someone else" here.

while C0D312 is working on the proper solution to this "absolute path" issue, i hacked his plugin to give me behavior that works for me and i think will work for you. i found that all i needed to do was to add a couple lines to the code in the plugin.

NOTE: the first two lines below are C0D312's code and the second two lines are what i added directly afterwards.

Code: Select all
        if cur_path.startswith(("'","\"","(")):
            cur_path = cur_path[1:-1]
        if cur_path.startswith("/"):
            cur_path = "." + cur_path


you can see my conversation with C0D312 about this issue here.
pjv
 
Posts: 30
Joined: Fri Feb 04, 2011 6:34 pm

Re: Plugin to hlep with img tags in HTML

Postby handycam on Thu Apr 26, 2012 10:52 am

alexrussell wrote: In case you don't know, Dreamweaver will autocomplete the 'src' attribute from the current file path, and also on confirmation of the autocomplete with fill in the 'width' and 'height' attributes too.


BBEdit does this too, it's very helpful. Would be awesome to have this in ST2.
Mac OS 10.8.5
ST 3 (3053)
handycam
 
Posts: 269
Joined: Tue Jan 03, 2012 2:42 pm

Re: Plugin to hlep with img tags in HTML

Postby pjv on Thu Apr 26, 2012 11:45 am

handycam wrote:
alexrussell wrote: In case you don't know, Dreamweaver will autocomplete the 'src' attribute from the current file path, and also on confirmation of the autocomplete with fill in the 'width' and 'height' attributes too.


BBEdit does this too, it's very helpful. Would be awesome to have this in ST2.


i'm playing with writing a plugin for this. if i have success will report back. i could do it for os x only using a command line call to get the image dimensions, but i would like to see first if i can make a cross-platform plugin that everyone can use. in order to do this, as far as i can tell, the package will need to embed the python Image module and i'm not sure how (yet) to go about packaging up a module like that such that it will work for everyone. i'm exploring.
pjv
 
Posts: 30
Joined: Fri Feb 04, 2011 6:34 pm

Re: Plugin to hlep with img tags in HTML

Postby pjv on Thu Apr 26, 2012 12:26 pm

i just made a nice discovery. the zen coding plugin already has the ability to update the height and width attributes of img tags for .png, .gif, and .jpg images (and he does it without embedding the python image module). all you have to do is have the cursor inside the img tag and trigger an action. the key sequence is platform dependent and i don't know the others, but on the mac it's ctrl-alt-shift-m.

err... looking at the zen coding code, it is deep. and really nicely written. i think it would be too difficult to try to extract the image size functionality and put it into C0D312's plugin because bits and pieces of the functionality are scattered through many functions and modules in zen coding. it might be nice for C0D312 to see if zen coding is available and if so, to auto-trigger the update size action from it if such inter-plugin communication is possible.
pjv
 
Posts: 30
Joined: Fri Feb 04, 2011 6:34 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 22 guests