The same image can be posted a number of times at different sizes, for example:
To deal with this we will simply store the tag position in the database relative to the full sized image, and scale the tags on each image to match the resized image. Our initial prototype (and the one running on this blog) did not have this however it has been implemented on the latest prototypes as such:
/**
* Get the original size of an image
* @param {string} img The location of the image
* @return {{width: number, height: number}} The dimensions of the image
*/
me.jscott.taggr.getImageSize = function (img) {
var i = new Image();
i.src = img;
return {“width”: i.width, “height”: i.height}
}
var original_size = me.jscott.taggr.getImageSize(imgs[i].src);
var size = goog.style.getSize(imgs[i]);
imgs[i].setAttribute(‘_tgr_width_scale’, size.width / original_size.width);imgs[i].setAttribute(‘_tgr_height_scale’, size.height / original_size.height);// …// position taggoog.style.setSize(container, new goog.math.Size(parseInt(a.getAttribute(“_tgr_width”),10), parseInt(a.getAttribute(“_tgr_height”),10)));goog.style.setPosition(container, new goog.math.Coordinate(parseInt(a.getAttribute(“_tgr_absolute_x”),10), parseInt(a.getAttribute(“_tgr_absolute_y”),10));