We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20413
    • 2,877 Posts
    @Jako LOL - Thanks for the pointers! smiley I will look into it ASAP.

    Update This will be my final approach https://twitter.com/hawproductions/status/437738855605624832

    Update2 THIS CDN IS NICE AND SOMETHING I WOULD USE: http://www.pixtulate.com/docs/index.htm
    >> See snippet below! smiley [ed. note: mrhaw last edited this post 10 years, 2 months ago.]
      @hawproductions | http://mrhaw.com/

      Infograph: MODX Advanced Install in 7 steps:
      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
      • 20413
      • 2,877 Posts


      <?php
      /*
      pixtulate parameters: http://pixtulate.com/docs/crop.htm#cookbook
      parameter	description								type				mandatory					default
      w, width	desired width							int, %, ‘max’		not if height is given	 
      h, height	desired height							int, %, ‘max’		not if width is given	 
      tlc			top left corner of crop area			int, ‘min’, ‘max’	not if brc is given	 
      brc			bottom right corner of crop area		int, ‘min’, ‘max’	not if tlc is given	 
      fp			focal point where to center crop area	int					no	 
      dpr			device pixel resolution					decimal				no							1
      
      Typical screen widths: https://developer.android.com/guide/practices/screens_support.html
      320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
      480dp: a tweener tablet like the Streak (480x800 mdpi).
      600dp: a 7” tablet (600x1024 mdpi).
      720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
      */	
      $output = '';
      
      $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
      //mobile android
      if(stripos($ua,'android') !== false && stripos($ua,'mobile') !== false) {
      	$detect = "400";
      }
      //mobile iphone
      elseif(stripos($ua,'iphone') !== false) {
      	$detect = "400";
      }
      //tablet android
      elseif(stripos($ua,'android') !== false && stripos($ua,'mobile') == false) {
      	$detect = "600";
      }
      //tablet ipad
      elseif(stripos($ua,'ipad') !== false) {
      	$detect = "600";
      }
      //laptop
      else {
      	$detect = "800";
      }
      
      //snippet parameters
      $api  	= isset($api) 	? $api 	: 'http://demo.api.pixtulate.com/';
      $pic  	= isset($pic) 	? $pic 	: 'demo/large-4.jpg';
      $alt  	= isset($alt) 	? $alt 	: '';
      $w  	= isset($w) 	? $w 	: $detect;
      $h  	= isset($h)		? $h 	: '';
      $tlc  	= isset($tlc) 	? $tlc 	: '';
      $brc  	= isset($brc) 	? $brc 	: '';
      $fp  	= isset($fp) 	? $fp 	: '';
      $dpr  	= isset($dpr) 	? $dpr 	: '1';
      
      $data = array(
      	'tlc'	=>	$tlc,
          'brc'	=>	$brc,
          'w'		=>	$w,
      	'h'		=>	$h,
      	'fp'	=>	$fp,
      	'dpr'	=>	$dpr
      );
      $src = $api . $pic . "?" . http_build_query($data);
      $output = '<img src="'. $src .'" alt="'. $alt .'">'; 
      return $output;
      ?>
      


      [!pixtulate!]

      or

      [!pixtulate?w=`900` &tlc=`-70,56`!]


      github >> https://github.com/mrhaw/Pixtulate-MODX-Snippet [ed. note: mrhaw last edited this post 10 years, 2 months ago.]
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower