How to limit resizing

  • So I have been trying to get a good solution regarding resizing of an image based on the size of the browser. Andrey (Mindlessboss) has been great trying to help and I've found several different solutions but seem to have a common issue. Based on the code below, when the browser loads it is .7 of the screenheight and screenwidth. When the browser gets smaller it still maintains the .7. Simple right!

    Problem I'm having is the .7 ratio is fine if you are on a typical laptop with a screen size of 1366 x 768, but when you're on a 27inch imac 2650 x 1440 the image is too big and even when you are on an iphone it shrinks too much.

    So the question is how would or could I adapt the code to prevent the image from expanding beyond 1366 and prevent it from shrinking too much on an iphone?

    I've tried different bits of code, but using if statements with stagewidth GT 800 etc.. creates other problems.

    Thanks in advance for your help!

    Robert

  • Sorry Umalo,

    I'm not a programmer and what knowledge I do have is limited. What do I replace, what do I remove to add your example. Do I add it to the fix_infobox_aspectsize?? Do I remove some code. When I add it everything stays at .7 regardless.

    Sorry very frustrated with more myself that I don't understand. I don't understand the correlation between plugin sizes and stage sizes especially when there are no height width settings and it is being retrieved in a statement based on the actual size of the image. Throw in mul and my brain hurts *unsure*

    I've attached the xml here if you wouldn't mind looking at it again.

    Thanks,

    Robert

  • Delete <info_box_settings... >
    Replace old action with this:

    Code
    <action name="fix_infobox_aspectresize">
    	if(%2 LE %1,mul(new_infobox_image_width,stagewidth,calc(stagewidth GE 1366 ? 0.5 : 0.9));
    	set(plugin[infobox_image].width,get(new_infobox_image_width));
    	set(plugin[infobox_image].height,prop);
    	,
    	mul(new_infobox_image_height,stageheight,calc(stageheight GE 768 ? 0.5 : 0.9));
    	set(plugin[infobox_image].height,get(new_infobox_image_height));
    	set(plugin[infobox_image].width,prop);); 
    	</action>


    In words: If screen width is greater than 1366 your image will be scaled to 0.5 (50% of it's size), otherwise it will be 0.9. Same with screeheight. You can adapt scale how you like. This is solution that will work in case of screen orientation change too. If we tweak only settings based solution than this is set on start and not udapted if screen size is changed like in case orientation change is happening.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!