Search code examples
javascriptimagefine-uploader

FineUploader: Track Scaled Images ClientSide


We're using FineUploader to upload files to a REST service. The current version of FineUploader allows for automatic upload of scaled images as detailed here.

FineUploader has ways to track scaled images in relation to their original image on the Server side. How do we track scaled images on the client side after successfully uploading an image?

  • Having the server determine what is/isn't a scaled image is not an option, this has to all be handled on the client.
  • FineUploader allows text to be appended to the end of scaled file names, however I don't want to use string matching as a mechanism to determine whether or not an image is scaled or not.

Solution

  • I appreciate the responses but I was able to find the answer by looking at the FineUploader API.

    It looks like the getParentId method is exactly what I was looking for.

    getParentId (scaledFileId)

    Get the ID of the parent file for this scaled file.

    Parameters:

    Integer id The ID of a scaled image file

    Returns:Integer Returns the ID of the scaled image's parent file. null if this is not a scaled image or a parent cannot be located.

    Here is some psuedo-code showing how to track this on the client-side in a FineUploader callback:

    callbacks: {
                onComplete: function (id, fileName, responseJSON, xhr) {
                    var isThumbnail = this.getParentId(id) !== null ? true : false;
                }
    }