From fc5c97af0ca0845c8d36935b5684dc705aeb679a Mon Sep 17 00:00:00 2001 From: Liam Cain Date: Wed, 23 Jan 2013 20:19:29 -0500 Subject: [PATCH] by request, added option to insert img's width first --- autofilename.py | 14 ++++++++++++-- autofilename.sublime-settings | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/autofilename.py b/autofilename.py index f0dd5d4..004b929 100644 --- a/autofilename.py +++ b/autofilename.py @@ -16,6 +16,12 @@ class InsertDimensionsCommand(sublime_plugin.TextCommand): dimension = str(dim) view.insert(edit, sel+1, ' '+name+'="'+dimension+'"') + def get_setting(self,string,view=None): + if view and view.settings().get(string): + return view.settings().get(string) + else: + return sublime.load_settings('autofilename.sublime-settings').get(string) + def run(self, edit): view = self.view view.run_command("commit_completion") @@ -35,8 +41,12 @@ class InsertDimensionsCommand(sublime_plugin.TextCommand): with open(full_path,'rb') as r: read_data = r.read() if path.endswith(('.jpg','.jpeg')) else r.read(24) con_type, w, h = getImageInfo(read_data) - self.insert_dimension(edit,w,'width',tag_scope) - self.insert_dimension(edit,h,'height',tag_scope) + if self.get_setting('afn_insert_width_first',view): + self.insert_dimension(edit,h,'height',tag_scope) + self.insert_dimension(edit,w,'width',tag_scope) + else: + self.insert_dimension(edit,w,'width',tag_scope) + self.insert_dimension(edit,h,'height',tag_scope) class ReloadAutoCompleteCommand(sublime_plugin.TextCommand): def run(self,edit): diff --git a/autofilename.sublime-settings b/autofilename.sublime-settings index 757929f..4b70fdc 100644 --- a/autofilename.sublime-settings +++ b/autofilename.sublime-settings @@ -15,5 +15,10 @@ // Whether or not AutoFileName should insert the width // and height dimensions after inserting an image into // an image tag - "afn_insert_dimensions": true + "afn_insert_dimensions": true, + + // If afn_insert_dimensions is true, by default, AutoFileName + // will insert height="" than width="". Setting this to true + // will switch the order in which they are inserted. + "afn_insert_width_first": false } \ No newline at end of file