WordPress Plugin
The WordPress plugin (bttpirineus-maps) converts [map] shortcodes into iframes that load the Next.js embed viewer.
Version: 1.3.0
File: wordpress/bttpirineus-maps/bttpirineus-maps.php
Installation
- Copy the
wordpress/bttpirineus-maps/folder - Upload it to
wp-content/plugins/on the WordPress server - Go to Plugins in wp-admin and activate BTT Pirineus Maps
- If you have a caching plugin (WP Super Cache, etc.), purge the cache
- Visit any page that had a broken
[map]shortcode — it should now show a map
Configuration
The only setting is the BTTPIRINEUS_EMBED_DOMAIN constant at the top of bttpirineus-maps.php:
define('BTTPIRINEUS_EMBED_DOMAIN', 'https://btt-pirineus-embedded.vercel.app');Set it to your Vercel production URL (no trailing slash).
Shortcode attributes
[map gpx="https://...ruta.gpx" chart="auto" title="My Route"]| Attribute | Required | Default | Description |
|---|---|---|---|
gpx | Yes | — | URL to the GPX file |
style | No | — | Inline CSS. If it contains height:Xpx, uses fixed-height mode |
chart | No | auto | Chart visibility: auto, show, hide |
title | No | GPX filename | Custom display title in the bottom bar |
Ignored legacy attributes: bike, maptype, pano, marker — silently accepted for backwards compatibility.
How it works
Shortcode processing
- Extracts
gpxattribute, strips trailing commas/semicolons - Resolves relative URLs (prepends
https://www.bttpirineus.org) - Generates a stable anchor ID from the GPX filename:
map-{sanitized-name} - Builds the iframe src:
{EMBED_DOMAIN}/embed?gpx=...&chart=...&page=...&anchor=... - Wraps in a
.bttmap-wrapdiv with lazy-loading iframe
Fixed-height vs responsive mode
- Fixed-height: If the shortcode has
style="height:400px", the wrapper gets that height + 200px (extra space for the elevation chart and bottom bar) - Responsive: If no explicit height, uses
aspect-ratio: 16/9withmin-height: 300pxandmax-height: 600px
Lazy loading
Iframes use data-src instead of src. An IntersectionObserver script in the footer swaps data-src to src when the iframe is within 200px of the viewport. This prevents inflated view counts on pages with many maps (a page with 8 maps would otherwise register 8 views immediately).
Fallback: if IntersectionObserver is not available, all iframes load immediately.
FitVids.js workaround
Many WordPress themes include FitVids.js, which wraps iframes in a .fluid-width-video-wrapper with a padding-top trick for responsive videos. With our iframes (width="100%", height="480px"), FitVids calculates 480/100 = 4.8 → 480% padding, blowing up the iframe to ~3400px tall.
The plugin injects CSS that resets FitVids wrappers inside .bttmap-wrap:
.bttmap-wrap .fluid-width-video-wrapper {
position: static !important;
padding: 0 !important;
width: 100% !important;
height: 100% !important;
}