Skip to content

Commit

Permalink
Allow displaying image in POIs (#389)
Browse files Browse the repository at this point in the history
* Add image to POIs

* fix missing quote

* Swap <hr> position
  • Loading branch information
Emojigit committed Jun 28, 2024
1 parent 89ea214 commit 070c7f7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions mapobject/poi.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (this *PoiBlock) onMapObject(mbpos *types.MapBlockCoords, x, y, z int, bloc
o.Attributes["name"] = md["name"]
o.Attributes["category"] = md["category"]
o.Attributes["url"] = md["url"]
o.Attributes["image"] = md["image"]
o.Attributes["owner"] = md["owner"]
o.Attributes["icon"] = md["icon"]
o.Attributes["color"] = this.Color
Expand Down
5 changes: 5 additions & 0 deletions public/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ body {
.player-popup div.info {
grid-area: info;
}

.poi_image {
width: 100%;
height: auto;
}
23 changes: 14 additions & 9 deletions public/js/map/overlays/PoiOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,23 @@ export default AbstractIconOverlay.extend({
},

createPopup: function(poi){
var innerHTML = "";

if (poi.attributes.url)
{
return "<a href=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.url) + "\">" +
"<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4></a><hr>" +
"<b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>";
if (poi.attributes.url) {
innerHTML += "<a href=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.url) + "\">" +
"<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4></a>";
} else {
innerHTML += "<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4>";
}
else
{
return "<h4>" + HtmlSanitizer.SanitizeHtml(poi.attributes.name) + "</h4><hr>" +
"<b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>";

if (poi.attributes.image) {
innerHTML += "<img class=\"poi_image\" src=\"" + HtmlSanitizer.SanitizeHtml(poi.attributes.image) +
"\" crossorigin=\"anonymous\" referrerpolicy=\"origin-when-cross-origin\">";
}

innerHTML += "<hr><b>Owner: </b> " + HtmlSanitizer.SanitizeHtml(poi.attributes.owner) + "<br>";

return innerHTML;
}


Expand Down

0 comments on commit 070c7f7

Please sign in to comment.