Skip to content

Responsive images with srcset #77

@mprofitlich

Description

@mprofitlich

Issue #41 was similar and got closed but I could not find a solution yet, although the closing comment states a PR had a fix.

I understand the script expects the image to be at the image map's size. If that's not the case the scale calculated factor is wrong. I accept to loose some automation and I added data attributes to the image map that give the original size.

// Image Map in HTML with data attributes
<map name="map-name" data-map-width="950" data-map-height="690">

// var scalingFactor
width  : image.width  / mapOriginalWidth,
height : image.height / mapOriginalHeight

// function setup
mapOriginalHeight     = map.getAttribute("data-map-height");
mapOriginalWidth      = map.getAttribute("data-map-width");

// var
mapOriginalHeight = null,
mapOriginalWidth = null;

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