Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-engine   php

Repository URL to install this package:

Version: 2.7.7 

/ js / admin / blocks-views / src / utils / image-sizes.js

export function getAvailableImageSizes(imageID, callback) {
	$.post(
		ajaxurl, {
			action: 'jet_guten_get_available_image_sizes',
			image_id: imageID
		},
		(response) => {
			callback(response);
		}
	);
}

export function getImageSizeName(url, imageSizes) {
	let currentSize = imageSizes.find(size => {
		return size.value === url;
	});

	return currentSize ? currentSize.label : 'full';
}

export function getImageURLBySizeName(imageSizeName, imageSizes) {
	let currentSize = imageSizes.find(size => {
		return size.label === imageSizeName;
	});

	return currentSize ? currentSize.value : imageSizes[0].value;
}