born05 / craft-imagehotspots

Image Hotspots fieldtype for Craft CMS
Other
5 stars 3 forks source link

FR: Support linking hotspots as a custom field within an Asset Volume #7

Closed matteveryday closed 3 years ago

matteveryday commented 3 years ago

I'm curious if it's possible to add one or multiple (via matrix) hotspots to an image via a custom field within that image's asset volume. The goal would be that wherever that particular image were used, the hotspot data would be maintained and available in the templates.

Screen Shot 2021-07-02 at 4 29 20 PM

Conceptually, when I query for an asset, I can access all of it's hotspots directly...

{% set image = entry.assetFieldHandle.one() %}
<div style="position: relative">
    <img src="{{ image.url() }}" style="width: 100%;" />
    {% for tag in image.productTags %}
        {% if tag.hotspotTag|length %}
        <div style="position: absolute; top: {{ tag.hotspotTag.y * 100 }}%; left: {{ tag.hotspotTag.x * 100 }}%"></div>
        {% endif %}
    {% endfor %}
</div>

Hoping my explanation makes sense, but happy to clarify any questions if need be.

roelvanhintum commented 3 years ago

Hi @matteveryday, currently this doesn't work, but adding it directly to an asset seems like a good addition!

roelvanhintum commented 3 years ago

@matteveryday 1.2.0 has support for your setup.