Skip to content

Commit

Permalink
use function context for file info, not the path node
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Mar 21, 2015
1 parent 8f11538 commit 125a7f0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/less-node/image-size.js
Expand Up @@ -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);
Expand All @@ -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");
}
};
Expand Down

0 comments on commit 125a7f0

Please sign in to comment.