Get image sizes

jQuery(document).ready(function($){
        
    $('img.am2_list_img').one('load', function() {
      
        // Get on screen image
        var screenImage = $(this);

        // Create new offscreen image to test
        var theImage = new Image();
        theImage.src = screenImage.attr("src");

        // Get accurate measurements from that.
        var imageWidth = theImage.width;
        var imageHeight = theImage.height;

        /*console.log(theImage);
        console.log(imageWidth);
        console.log(imageHeight);
        console.log("-----");*/


        // e sad ide if...
        if(imageHeight < imageWidth ){
            //console.log("height je manji od width - LANDSCAPE");
            screenImage.addClass("landscape");
        } else if(imageHeight === imageWidth) {
            //console.log("height je jednak width - SQUARE");
        } else {
            //console.log("height je VEĆI od width - PORTRAIT");
            screenImage.addClass("portrait");
        }
      
      
    }).each(function() {
        if(this.complete) $(this).load();
    });
        
        
});

 

PHP date to JS date

Kako pouzdano iz PHP-a setapirati JS date

$tz = new DateTimeZone($this_city_tz);
$date = new DateTime();
$date->setTimeZone($tz);
$date_time = $date->format('Y-m-d H:i:s');
$date_time_js = $date->format('Y/m/d H:i:s');

var currentDate = new Date('<?php echo gmdate("r", strtotime($date_time_js)); ?>');

console.log(currentDate);