ferda2
Forum Replies Created
-
Okay, thanks for the information.
Perfect, thanks! I modified the snippet for more custom fields + character cutoff (155).
Forum: Plugins
In reply to: [Lightbox for Gallery & Image Block] Custom post templateThank you for your help!
Forum: Plugins
In reply to: [Lightbox for Gallery & Image Block] Custom post template<div class="<?php echo esc_attr($class); ?>"> <a href="<?php echo esc_url($full_image_url); ?>" title="<?php echo esc_attr($title); ?>"> <img src="<?php echo esc_url($full_image_url); ?>" alt="<?php echo esc_attr($alt); ?>" title="<?php echo esc_attr($title); ?>"> </a> <?php if ($caption): ?> <div class="pes-info-caption"><?php echo esc_html($caption); ?></div> <?php endif; ?> </div>Forum: Plugins
In reply to: [Lightbox for Gallery & Image Block] Custom post templateI have the website on localhost now.
Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)Thank you. How to use the URL replacement script in this plugin?
Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)A fully functional page.
<!DOCTYPE html>
<html>
<head>
<title>Leaflet KML with Popups</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://unpkg.com/leaflet/dist/leaflet.css"
/>
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/leaflet-omnivore.min.js"></script>
<style>
#map { height: 500px; }
</style>
</head>
<body>
<div id="map"></div>
<script>
var map = L.map('map').setView([37.7749, -122.4194], 10);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(map);
// Load KML
var kmlLayer = omnivore.kml('castle.kml');
kmlLayer.on('ready', function() {
map.fitBounds(kmlLayer.getBounds());
});
// Add popups to features
kmlLayer.on('layeradd', function(e) {
var layer = e.layer;
if (layer.feature && layer.feature.properties) {
var props = layer.feature.properties;
var popupContent = '';
if (props.name) {
popupContent += '<strong>' + props.name + '</strong>';
}
if (props.description) {
// Convert raw URLs into clickable links
var modifiedDescription = props.description.replace(
/https?:\/\/[^\s<"]+/g,
function(url) {
return '<a href="' + url + '" target="_blank" rel="noopener noreferrer">' + url + '</a>';
}
);
popupContent += '<br>' + modifiedDescription;
}
if (popupContent) {
layer.bindPopup(popupContent);
}
}
});
kmlLayer.addTo(map);
</script>
</body>
</html>Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)Editing the script for geojson:
--- ORIGINAL ---
var updatedDescription = description.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1">$1</a>');
--- NEW ---
var updatedDescription = description.replace(/((https):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g, '<a href="$1">$1</a>');Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)The example works, but the file must be geojson (not KML). The resulting links are incorrect, specifically:
<a href="https://www.xxx.com<br>https://www.facebook.com/groups/xxx">https://www.xxx.com<br>https://www.facebook.com/groups/xxx</a>Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)I’ll test it after the weekend. Thank you.
Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)The data is from Google Maps. The KML contains:
<Placemark>
<name>Castle 1</name>
<description><![CDATA[Place:<br>xxx ...<br><br>Contact:<br>phone.: xxx<br>email: [email protected]<br><br>Website:<br>https://www.xxx.com<br>https://www.facebook.com/groups/xxx]]></description>Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)I found a script that might solve this. But it will probably be necessary to add the kmlLayer layer using a shortcode.
<script>
var kmlLayer = L.KML("castles.kml");
kmlLayer.on('addlayer', function(e) {
var feature = e.layer;
if (feature.feature && feature.feature.properties && feature.feature.properties.description) {
var description = feature.feature.properties.description;
// Use regex to find URLs and convert them to links
var updatedDescription = description.replace(/(https?:\/\/[^\s]+)/g, '<a href="$1">$1</a>');
feature.bindPopup(updatedDescription);
}
});
kmlLayer.addTo(map);
</script>Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)The link is in the description. There is more text in the description (address, phone, URL, etc.).
<p>{name}</p> = Only name, NO link …
<p>{description}</p> = More text including link …
Forum: Plugins
In reply to: [Extensions for Leaflet Map] Find URLs and convert them to links (KML)Hi, the code is fine. The KML file contains URLs in the description without HTML tags (a href). I need to convert the URLs to active (add HTML tags). I believe there is a solution (function).
Excellent, thank you!