Adblock breaks this site

Auto-Size adjustment for large images

Discussion in 'Approved Suggestions' started by iBlackHornet, Jul 23, 2013.

Thread Status:
Not open for further replies.
  1. iBlackHornet

    iBlackHornet Forum Addict
    Banned

    Joined:
    Feb 11, 2012
    Posts:
    507
    Referrals:
    0
    Sythe Gold:
    3
    Auto-Size adjustment for large images

    I've seen this on a few forums. If the title doesn't explain it well to you, then I'm gonna explain it briefly.

    There are a lot of threads in which a person posts a picture of large dimensions i.e. 1920x1080 or larger. For someone using a computer with resolution smaller than the image (i.e. 800x600 or 1280x1024), the horizontal scroll will appear.

    My suggestion is that if an image is posted which is larger than a specific size, the image size will be auto adjusted to a smaller size (x0.5 of original)
    Like, if an image is posted of dimensions 2000x1400, it will be auto-resized to 1000x700.

    The larger image should be auto-resized to half as default, but one can press a button, to have it back to original size.

    Example of a large image that gets auto-adjusted to a smaller size:

    [​IMG]

    I hope you get what I'm trying to say. If you've any queries regarding this or just don't get what I meant, post below or PM me.
     
  2. R

    R Legend
    Retired Administrator Roary Donor Mudkips Legendary

    Joined:
    Apr 4, 2011
    Posts:
    19,571
    Referrals:
    16
    Sythe Gold:
    572
    In Memory of Jon <3 n4n0 Sythe Awards 2013 Winner
    Auto-Size adjustment for large images

    If possible, would be good for folks like me with stone-age monitors ;)
     
  3. AmitZ

    AmitZ #SOFUGGNSTONED M8
    Banned

    Joined:
    Jan 6, 2010
    Posts:
    2,866
    Referrals:
    0
    Sythe Gold:
    0
    Auto-Size adjustment for large images

    Support. This is much needed.
     
  4. n4n0

    n4n0 Legend
    Village Drunk Legendary Heavenly Highly Respected

    Joined:
    Jun 17, 2007
    Posts:
    14,207
    Referrals:
    66
    Sythe Gold:
    10,701
    Poképedia
    Charmeleon Abra Gastly
    Tier 1 Prizebox (15) Live Streamer Pokémon Trainer (15) The Dark Side Oktoberfest 2013 MushyMuncher (2) Rupee (4) St. Patrick's Day 2013 Poker Chip
    Not sure if srs or just newfag... (9) Ninja Tortoise Penis DIAF St. Patrick's Day 2014 Cool Kid (6) Cook (4) Heidy (17) Halloween 2013 Village Drunk (8)
    Voluntaryist (3) We Are Legion (4) Penguin (9)
    Auto-Size adjustment for large images

    Wouldn't mind seeing this. It has my support, and I'll try and push it to Sythe when I get the time.
     
  5. Syed

    Syed Hero
    Retired Sectional Moderator $50 USD Donor New

    Joined:
    Jan 22, 2009
    Posts:
    9,857
    Referrals:
    1
    Sythe Gold:
    11
    Sythe Awards 2012 Winner Gohan has AIDS (3) ??? Rust Player I'm LAAAAAAAME (2) Shitting Rainbow (2)
    Auto-Size adjustment for large images

    There are multiple image resizers for vbulletin already available, so of course it's possible.

    And yea, support.
     
  6. Add My Msn

    Add My Msn Selling OSRS Accounts!
    $50 USD Donor New

    Joined:
    Sep 3, 2010
    Posts:
    10,005
    Referrals:
    0
    Sythe Gold:
    3,582
    Vouch Thread:
    Click Here
    Sythe's 10th Anniversary Top Striker Two Factor Authentication User SytheSteamer In Memory of Jon Dragon Claws Secret Santa Rio 2016 Battleship Champion
    Pool Shark
    Auto-Size adjustment for large images

    Support. neo's pics are always big -.-
     
  7. Sythe

    Sythe Join our discord

    test

    Administrator Village Drunk

    Joined:
    Apr 21, 2005
    Posts:
    8,071
    Referrals:
    467
    Sythe Gold:
    5,281
    Discord Unique ID:
    742989175824842802
    Discord Username:
    Sythe
    Dolan Duck Dolan Trump Supporting Business ???
    Poképedia
    Clefairy Jigglypuff
    Who did this to my freakin' car!
    Hell yeah boooi
    Tier 3 Prizebox Toast Wallet User
    I'm LAAAAAAAME Rust Player Mewtwo Mew Live Free or Die Poké Prizebox (42) Dat Boi
    Auto-Size adjustment for large images

    I would do it client-side only. Anyone got a link to a page on a site that already does this? Can probably borrow some code and save some time.
     
  8. Syed

    Syed Hero
    Retired Sectional Moderator $50 USD Donor New

    Joined:
    Jan 22, 2009
    Posts:
    9,857
    Referrals:
    1
    Sythe Gold:
    11
    Sythe Awards 2012 Winner Gohan has AIDS (3) ??? Rust Player I'm LAAAAAAAME (2) Shitting Rainbow (2)
    Auto-Size adjustment for large images

    This works, however you'll need jQuery to use this. Modified one I found on stackoverflow to work on vbulletin. Tried it out in the chrome console on Delta's alcohol thread, worked fine as far as I can see. I coulda made it resize based on browser width, but im2lazy.

    Code:
    $(window).load(function() {
    	$('div[id^="post_message_"]').find('img').each(function() {
    		var maxWidth = 800; // Max width for the image
    		var maxHeight = 800;    // Max height for the image
    		var ratio = 0;  // Used for aspect ratio
    		var width = $(this).width();    // Current image width
    		var height = $(this).height();  // Current image height
    
    		// Check if the current width is larger than the max
    		if(width > maxWidth){
    			ratio = maxWidth / width;   // get ratio for scaling image
    			$(this).css("width", maxWidth); // Set new width
    			$(this).css("height", height * ratio);  // Scale height based on ratio
    			height = height * ratio;    // Reset height to match scaled image
    			width = width * ratio;    // Reset width to match scaled image
    			$(this).wrap('<table><tr><td class="tborder"><div class="resized_image"><a href="' + this.src + '" target="_blank"></a></div></td></tr></table>');
    			$(this).parent().before('<p style="padding-left:10px;">NOTE: This image was resized. To view it full-size, click on the image.</p>');
    		}
    
    		// Check if current height is larger than max
    		if(height > maxHeight){
    			ratio = maxHeight / height; // get ratio for scaling image
    			$(this).css("height", maxHeight);   // Set new height
    			$(this).css("width", width * ratio);    // Scale width based on ratio
    			width = width * ratio;    // Reset width to match scaled image
    		}
    	});
    });
    
     
  9. Swadq

    Swadq Forum Addict
    $5 USD Donor New

    Joined:
    May 23, 2013
    Posts:
    426
    Referrals:
    0
    Sythe Gold:
    0
    Two Factor Authentication User
    Auto-Size adjustment for large images

    Code:
    $(window).load(function() {
    	$('div[id^="post_message_"]').find('img').each(function() {
    		var $this = $(this);
    		var maxWidth = 800; // Max width for the image
    		var maxHeight = $(window).width() - 80;    // Max height for the image. Will have to change if CSS changes
    		var ratio = 0;  // Used for aspect ratio
    		var width = $this.width();    // Current image width
    		var height = $this.height();  // Current image height
    
    		// Check if the current width is larger than the max
    		if(width > maxWidth){
    			ratio = maxWidth / width;   // get ratio for scaling image
    			$this.css("width", maxWidth); // Set new width
    			$this.css("height", height * ratio);  // Scale height based on ratio
    			height = height * ratio;    // Reset height to match scaled image
    			width = width * ratio;    // Reset width to match scaled image
    			$this.wrap('<table><tr><td class="tborder"><div class="resized_image"><a href="' + this.src + '" target="_blank"></a></div></td></tr></table>');
    			$this.parent().before('<p style="padding-left:10px;">NOTE: This image was resized. To view it full-size, click on the image.</p>');
    		}
    
    		// Check if current height is larger than max
    		if(height > maxHeight){
    			ratio = maxHeight / height; // get ratio for scaling image
    			$this.css("height", maxHeight);   // Set new height
    			$this.css("width", width * ratio);    // Scale width based on ratio
    			width = width * ratio;    // Reset width to match scaled image
    		}
    	});
    });
    
     
  10. Syed

    Syed Hero
    Retired Sectional Moderator $50 USD Donor New

    Joined:
    Jan 22, 2009
    Posts:
    9,857
    Referrals:
    1
    Sythe Gold:
    11
    Sythe Awards 2012 Winner Gohan has AIDS (3) ??? Rust Player I'm LAAAAAAAME (2) Shitting Rainbow (2)
    Auto-Size adjustment for large images

    Nice.

    Well if Sythe were going to implement this, he could just modify the above code.
     
  11. candarin

    candarin Potamus
    Banned

    Joined:
    May 11, 2013
    Posts:
    541
    Referrals:
    0
    Sythe Gold:
    0
    Auto-Size adjustment for large images

    Support excellent idea, lol.
     
  12. Superman

    Superman Legend
    Retired Administrator

    Joined:
    May 17, 2009
    Posts:
    19,919
    Referrals:
    11
    Sythe Gold:
    1,680
    Detective Two Factor Authentication User Doge
    Auto-Size adjustment for large images

    Thanks for the code Swadq. I'll forward this to Sythe as soon as he replies to my PM about another suggestion. Hopefully we can implement this sort of feature.
     
< Helping out other games | Some sort of hacking prevention system. >
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site