Skip to content

Added "fit" option to scale images to fit container #25

@Jalon

Description

@Jalon

Immediately after

                                var whenDimensions = function(width, height) {

Add this block:

                if (data.settings.fit === true)
                {
                    var ratio = Math.min(containerWidth/width, containerHeight/height);
                    width = Math.ceil(ratio * width);
                    height = Math.ceil(ratio * height);
                    $img.css({width: width});
                    $img.css({height: height});
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions