PHP Classes

File: public/js/tinymce/src/plugins/imagetools/src/main/js/core/ImageSize.js

Recommend this page to a friend!
  Classes of Abed Nego Ragil Putra   GoLavaCMS   public/js/tinymce/src/plugins/imagetools/src/main/js/core/ImageSize.js   Download  
File: public/js/tinymce/src/plugins/imagetools/src/main/js/core/ImageSize.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: GoLavaCMS
Publish content on Web pages with SEO support
Author: By
Last change:
Date: 6 years ago
Size: 1,752 bytes
 

Contents

Class file image Download
/** * ImageSize.js * * Released under LGPL License. * Copyright (c) 1999-2017 Ephox Corp. All rights reserved * * License: http://www.tinymce.com/license * Contributing: http://www.tinymce.com/contributing */ define( 'tinymce.plugins.imagetools.core.ImageSize', [ ], function () { function getImageSize(img) { var width, height; function isPxValue(value) { return /^[0-9\.]+px$/.test(value); } width = img.style.width; height = img.style.height; if (width || height) { if (isPxValue(width) && isPxValue(height)) { return { w: parseInt(width, 10), h: parseInt(height, 10) }; } return null; } width = img.width; height = img.height; if (width && height) { return { w: parseInt(width, 10), h: parseInt(height, 10) }; } return null; } function setImageSize(img, size) { var width, height; if (size) { width = img.style.width; height = img.style.height; if (width || height) { img.style.width = size.w + 'px'; img.style.height = size.h + 'px'; img.removeAttribute('data-mce-style'); } width = img.width; height = img.height; if (width || height) { img.setAttribute('width', size.w); img.setAttribute('height', size.h); } } } function getNaturalImageSize(img) { return { w: img.naturalWidth, h: img.naturalHeight }; } return { getImageSize: getImageSize, setImageSize: setImageSize, getNaturalImageSize: getNaturalImageSize }; } );