FORUM IS CLOSED. PLEASE USE QUESTIONS / ANSWERS PAGE INSTEAD
Login  |  Forum  |  Search   

Board index » Development » Other




Post new topic Reply to topic  [ 5 posts ] 
 
Author Message
 Post subject: TIP - Find images without Heigth specifications
 Post Posted: Sat Mar 10, 2012 10:02 am 
Offline

Joined: Wed Jul 27, 2011 10:12 am
Posts: 330
Location: Hong-Kong
Hello,

An HTML page renders faster if all the images, icons, etc have the width and height defined in the HTML code.

To very quickly find those which are not like that, do this.

- Export your SQL database, see IPs documentation.

- Open this .sql file in a text editor with Regular Expressions (RegEx) searches.
(e.g. the best is BBEdit on Macintosh).

- Replace all the <img by \r<img (\r is return). The goal is to have only one image link at the beginning of a line, so you can easily find it.

- Search for this regex pattern several times, or extract the lines responding to this criteria in a new text file (BBEdit: menu Text - Process Line Containing...)
width="\w+" [^height]

For each line found, you can easily see on which page if your images are sorted in different folders on your site.

If it is not the case, you will have to step back to the beginning of the widget bock.
<div class="ipWidget

After that, just go to the CMS and edit the image with the small tree icon in the Rich Text widget.

For other images widgets, I think that since version 1.15 the width and height are automatically set. Correct ? or is just in version 2 ?

Enjoy!


Last edited by Stf on Sun Mar 18, 2012 8:03 am, edited 1 time in total.

Top 
 Profile  
 
 Post subject: Re: TIP - Find images without Width or Length specifications
 Post Posted: Sat Mar 10, 2012 5:39 pm 
Offline
Project Developer

Joined: Tue Apr 28, 2009 9:43 am
Posts: 1720
I think better way would be to add image size in theme instead of directly accessing the database. We try to specify width and height where possible to speed up rendering. But we are in transition period. I'm not sure if it is done everywhere.


Top 
 Profile  
 
 Post subject: Re: TIP - Find images without Width or Length specifications
 Post Posted: Sun Mar 11, 2012 6:18 am 
Offline

Joined: Wed Jul 27, 2011 10:12 am
Posts: 330
Location: Hong-Kong
I do not see how this could be in the theme, I am mainly speaking of the image in a rich text widget, which allows to make 'model' that you can copy paste. eg. to present articles with the same layout, text areas, dimensions...

For the CMS user using the sql dump is the fastest method.
Checking all the images will waste too much time, specially if only a few are without Height.

I was thinking to make a javascript to compute the missing Height, but load delay, code sizes... would probably lead to problems. And also if the image has been resized...

What's strange is that tinymce stores the width but not the height!
You have to force it in the image dialog.

BTW, why are we still using version 2.8 of 2008 instead of latest one 3... something?

Thanks,


Top 
 Profile  
 
 Post subject: Re: TIP - Find images without Width or Length specifications
 Post Posted: Sun Mar 11, 2012 10:18 am 
Offline
Project Developer

Joined: Tue Apr 28, 2009 9:43 am
Posts: 1720
2.x uses the latest.


Top 
 Profile  
 
 Post subject: Re: TIP - Find images without Width or Length specifications
 Post Posted: Sat Mar 17, 2012 9:16 am 
Offline

Joined: Wed Jul 27, 2011 10:12 am
Posts: 330
Location: Hong-Kong
As the SQL output puts a lot of things on the same lines, here is the steps to do it.
Requires a Text Editor with Regex.
On Mac uses BBEdit (there is a free version I think) on PC I know this one (http://www.pspad.com/).

Replace
<img
by
\r<img

Replace
/>
by
/>\r

Extract all 'image' lines with the following condition. if you can not extract them to a new document, just do a Find in the entire file.

<img
Note, there is a space at the end of the previous line!

The above regex expression covers all the cases even in 'complex' languages (Chinese, Japanese...)

Search for the 'image' lines without Height value and edit the pages in IPs.
width="\w+" [^height]

That's it.


Top 
 Profile  
 
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 5 posts ] 

Board index » Development » Other


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: