Responsive design
-
What would I need to do and to what file, to not load the JS but do load an image (random or first in list) if the browser viewport is less than some dimension, say, 600 pixels? This is a need to be properly responsive so the user doesn’t download many images (or even large ones) when on a mobile device.
Below is my mod to the pub_footer.html.twig file. This did not work but rather killed the script completely.
if (screen.width<=799) { /*<![CDATA[*/ {# UNCOMPRESSED: try { (function($){ myatu_bgm.addTopImage( "{% if opacity < 100 %}-moz-opacity:.{{ opacity }};filter:alpha(opacity={{ opacity }});opacity:.{{ opacity }};{% endif %}", function() { // Either fade in or display immediately if ((typeof myatu_bgm !== "undefined") && (myatu_bgm.initial_ease_in === "true")) { $(this).fadeIn("slow"); } else { $(this).show(); } } ); }(jQuery)); } catch(e) {} #} try{(function(a){myatu_bgm.addTopImage("{% if opacity < 100 %}-moz-opacity:.{{ opacity }};filter:alpha(opacity={{ opacity }});opacity:.{{ opacity }};{% endif %}",function(){if((typeof myatu_bgm!=="undefined")&&(myatu_bgm.initial_ease_in==="true")){a(this).fadeIn("slow")}else{a(this).show()}})}(jQuery))}catch(e){}; /*]]>*/ } else { <img id="myatu_bgm_top" class="myatu_bgm_fs" src="{{ random_image.url }}" alt="{{ random_image.alt }}" {% if opacity < 100 %}style="-moz-opacity:.{{ opacity }}; filter:alpha(opacity={{ opacity }}); opacity:.{{ opacity }};"{% endif %} /> }
Thank you in advance.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Responsive design’ is closed to new replies.