@@ -11,7 +11,7 @@ def insert_dimension(self,edit,dim,name,tag_scope):
11
11
view = self .view
12
12
sel = view .sel ()[0 ].a
13
13
if name in view .substr (tag_scope ):
14
- reg = view .find ('(?<=name\=)\s*\" \d{1,5}' , tag_scope .a )
14
+ reg = view .find ('(?<=' + name + ' \=)\s*\" \d{1,5}' , tag_scope .a )
15
15
view .replace (edit , reg , '"' + str (dim .get (name )))
16
16
else :
17
17
dimension = str (dim .get (name ))
@@ -33,7 +33,7 @@ def run(self, edit):
33
33
path = path [path .rfind ('/' ):]
34
34
full_path = self .this_dir + path
35
35
if '<img' in view .substr (tag_scope ) and path .endswith (('.png' ,'.jpg' ,'.jpeg' ,'.gif' )):
36
- with open (full_path ,'r ' ) as r :
36
+ with open (full_path ,'rb ' ) as r :
37
37
read_data = r .read ()
38
38
dim = get_image_size (read_data )
39
39
self .insert_dimension (edit ,dim ,'width' ,tag_scope )
@@ -70,7 +70,7 @@ def will_commit(self, view):
70
70
def fix_dir (self ,sdir ,fn ):
71
71
if fn .endswith (('.png' ,'.jpg' ,'.jpeg' ,'.gif' )):
72
72
path = os .path .join (sdir + '/' , fn )
73
- with open (path ,'r ' ) as r :
73
+ with open (path ,'rb ' ) as r :
74
74
read_data = r .read ()
75
75
dim = get_image_size (read_data )
76
76
return fn + '\t ' + 'w:' + str (dim .get ('width' ))+ " h:" + str (dim .get ('height' ))
0 commit comments