mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
use function context for file info, not the path node
This commit is contained in:
@@ -3,10 +3,11 @@ var Dimension = require("../less/tree/dimension"),
|
||||
functionRegistry = require("./../less/functions/function-registry"),
|
||||
path = require("path");
|
||||
|
||||
function imageSize(filePathNode) {
|
||||
function imageSize(functionContext, filePathNode) {
|
||||
var filePath = filePathNode.value;
|
||||
var currentDirectory = filePathNode.currentFileInfo.relativeUrls ?
|
||||
filePathNode.currentFileInfo.currentDirectory : filePathNode.currentFileInfo.entryPath;
|
||||
var currentFileInfo = functionContext.currentFileInfo;
|
||||
var currentDirectory = currentFileInfo.relativeUrls ?
|
||||
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
|
||||
|
||||
var sizeOf = require('image-size');
|
||||
filePath = path.join(currentDirectory, filePath);
|
||||
@@ -15,18 +16,18 @@ function imageSize(filePathNode) {
|
||||
|
||||
var imageFunctions = {
|
||||
"image-size": function(filePathNode) {
|
||||
var size = imageSize(filePathNode);
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new Expression([
|
||||
new Dimension(size.width, "px"),
|
||||
new Dimension(size.height, "px")
|
||||
]);
|
||||
},
|
||||
"image-width": function(filePathNode) {
|
||||
var size = imageSize(filePathNode);
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new Dimension(size.width, "px");
|
||||
},
|
||||
"image-height": function(filePathNode) {
|
||||
var size = imageSize(filePathNode);
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new Dimension(size.height, "px");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user