PHP compress image size on the fly (Timthumb script – Validate XHTML)

Most of you might already heard of Timthumb php script to compress (re-size) images on fly. If you have not heard of it then please view this post from the author – Darren Hoyt.

This entry will not show you how to use it as you can read the full documentation and demo on the author’s blog.  I recently used Timthumb php script for quite few projects (TE,  Mary Chocolatier ..) and it actually save a lot of bandwidth and development time. However, all of the pages which use Timthumb script does not validate XHTML and generated many errors and warning messages.

To get the most out of TimThumb script and improve your pages to pass W3C XHTML validation check, please follow this below edit:

Original code:
<img src=”/scripts/timthumb.php?src=/images/whatever.jpg&h=150&w=150&;zc=1″ alt=”" />

Change it to:

<img src=”/scripts/timthumb.php?src=/images/whatever.jpg&amp;h=150&amp;w=150&amp;zc=1″ alt=”" />
Now come back to W3C Markup Validation Service to see how your page been approved.

This entry was posted in PHP, Web development and tagged , , , , . Bookmark the permalink.

10 Responses to PHP compress image size on the fly (Timthumb script – Validate XHTML)

  1. Trey says:

    Thanks a lot for this small fix :D

  2. Jepser says:

    Man! awsome thanks :)

  3. Samuel Musarika says:

    That saved me a lot of hassle, many thanks.

  4. That is excellent, I managed to implement timthumb onto my vivvo installation and it work perfectly. Thanks for you help guys.

  5. Freddie Lore says:

    I need this….thanks for this post..

  6. Bosphorus says:

    I would like to change it as you suggest, but where do I find the source code to make this a permanent edit for sitewide?

    I have found the timthumb script ok in /my-theme/scripts/timthumb.php, but I don’t see the code here to change it either…

    It would be great if you could let us know where to do it too. Thanks!

  7. Ramesh says:

    very good

  8. sridhar says:

    hi friends i am unable to write the image compression code in php.If u have then please send it to me…
    thanks in advance

  9. Rajpal says:

    Thank You

  10. Thanks a lot, i resolve now 22 errors! really awsome.
    Thanks for you help guys.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">