Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>On a rails app, I was lazy loading hundreds of mid-size photos (infinite scroll) and inevitably hit the 10Mb limit on the iphone. I tried loading the graphics into a canvas (new Image, src=, then Image.onload) but still hit the same limit. I also tried replacing the img src and removing it (when it went out of viewable area) but still no cigar. In the end, switching out all the img tags w/ div's w/ the photo as background did the trick.</p> <pre><code> $.ajax({ url:"/listings/"+id+"/big", async:true, cache:true, success:function(data, textStatus, XMLHttpRequest) { // detect iOS if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i)) { // load html into data data = $(data); // replace img w/ div w/ css bg data.find(".images img").each(function() { var src = $(this).attr("src").replace(/\s/g,"%20"); var div = $("&lt;div&gt;"); div.css({width:"432px",height:"288px",background:"transparent url("+src+") no-repeat"}); $(this).parent().append(div); $(this).remove(); }); // remove graphic w/ dynamic dimensions data.find(".logo").remove(); } // append element to the page page.append(data); } }); </code></pre> <p>I can now load well over 40Mb of photos on one page w/o hitting the wall. I encountered an odd issue, though, with some of the css background graphics failing to show up. A quick js thread fixed that. Set the div's css bg property every 3 sec's.</p> <pre><code> setInterval(function() { $(".big_box .images div.img").each(function() { $(this).css({background:$(this).css("background")}); }); }, 3000); </code></pre> <p>You can see this in action at <a href="http://fotodeck.com" rel="nofollow">http://fotodeck.com</a>. Check it out on your iphone/ipad.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload