BJ Lazy Load
[resolved] [FIX] Incorrect data-src encoding for non-english characters in filename (6 posts)

  1. testsiteoop
    Posted 1 year ago #


    First of all, a big thank you for such a nicely written and very functional plugin. I'm an amateur web developer just starting with WordPress, and found your code, both php and javascript, to be very descriptive and clear to understand.

    I was having a problem when the "hiDPI" and "responsive" images options were active (both, or either one by themselves). Images with non-english characters in their filenames (e.g. ñ, á, é, ó, among others) were not being displayed at all.
    A closer look revealed that the src parameter passed to thumb.php was incorrectly encoded for these characters. in fact, loading the image by itself in a new tab showed a TimThumb error "Could not find the internal image you specified."

    I traced the source of the problem to line 36 of the file js/bj-lazy-load.js:
    imgurl = BJLL.thumb_base + escape( srcimgurl ) + '&w=' + loadimgwidth;
    I noticed the use of the escape() javascript funcion, which, according to some googlin' was deprecated in JavaScript version 1.5. The use of encodeURI() or encodeURIComponent() is recommended instead, depending on the intended use:
    I changed the previous line to:
    imgurl = BJLL.thumb_base + encodeURIComponent( srcimgurl ) + '&w=' + loadimgwidth;
    And i'ts now working for me without any issues. "ñàâáçü©åœ®.jpg" gets downscaled and shown as expected.

    If you find that the above is correct and solves the issue, would you consider updating the plugin?

    Again, THX for such a nice piece of software. It works very good and transparent.

    PD: for anyone in need of a quick fix to this particular issue:

    1. Find the file "bj-lazy-load/js/combined.min.js".
    2. in line Nº20, find the spot where it says thumb_base+escape(l)
    3. replace the call to escape() so it reads thumb_base+encodeURIComponent(l)


  2. Bjørn Johansen
    Plugin Author

    Posted 1 year ago #

    You have no idea how happy I am to see a well written bug report like this. Awesome!

    I just released version 0.7.1 with your fix. Thank you!

    BTW: The whole image generator will very soon be entirely rewritten to use WP_Image_Editor instead.

  3. testsiteoop
    Posted 1 year ago #

    Thank you for the version update and kind words!

    Looking forward to that rewrite. Your plugin is indeed a very useful one.

    THX again,

    Andrés Cruz.

  4. Bjørn Johansen
    Plugin Author

    Posted 1 year ago #

    I pushed a beta version to GitHub just a few minutes ago if you want to test it: https://github.com/bjornjohansen/bj-lazy-load

    And I'd be very happy if you just took a few seconds to rate the plugin: http://wordpress.org/support/view/plugin-reviews/bj-lazy-load :-)

  5. testsiteoop
    Posted 1 year ago #


    Will check that beta!

  6. Bjørn Johansen
    Plugin Author

    Posted 1 year ago #

    Thanks a lot! :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • BJ Lazy Load
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic