// ...
getOrientation(file, function(orientation) {
if (orientation == 8) { // -90deg
$modal.trigger('image-action', [['left']]);
}
else if (orientation == 6) { // 90deg
$modal.trigger('image-action', [['right']]);
}
else if (orientation == 3) { // -180deg
$modal.trigger('image-action', [['left']]);
$modal.trigger('image-action', [['left']]);
}
});
// ...
function getOrientation(file, callback) {
var reader = new FileReader();
reader.onload = function(e) {
var view = new DataView(e.target.result);
if (view.getUint16(0, false) != 0xFFD8) return callback(-2);
var length = view.byteLength/2, offset = 2;
while (offset < length) {
var marker = view.getUint16(offset, false);
offset += 2;
if (marker == 0xFFE1) {
if (view.getUint32(offset += 2, false) != 0x45786966) return callback(-1);
var little = view.getUint16(offset += 6, false) == 0x4949;
offset += view.getUint32(offset + 4, little);
var tags = view.getUint16(offset, little);
offset += 2;
for (var i = 0; i < tags; i++)
if (view.getUint16(offset + (i * 12), little) == 0x0112)
return callback(view.getUint16(offset + (i * 12) + 8, little));
}
else if ((marker & 0xFF00) != 0xFF00) break;
else offset += view.getUint16(offset, false);
}
return callback(-1);
};
reader.readAsArrayBuffer(file);
}
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
<div class="col-lg-4 col-md-6 col-sm-12 col-12 mg">
<div class="project_block"></div>
</div>
</div>