Commit fb081902 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add embed support for umap

parent 7911604b
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -32,4 +32,15 @@ function fscoli_mime_types($mime_types){
    return $mime_types;
}
add_filter('upload_mimes', 'fscoli_mime_types', 1, 1);

// Add support to embed umap (umap.openstreetmap.de)
// See https://wordpress.org/support/article/embeds/#adding-support-for-a-non-oembed-site
// For more details on the parameters this function is called with, see also
// https://developer.wordpress.org/reference/classes/wp_embed/get_embed_handler_html/
function fscoli_embed_umap($regex_matches, $embed_attrs, $url, $raw_embed_attrs) {
    $width = $embed_attrs['width'];
    $height = $embed_attrs['height'];
    return "<iframe src='$url' style='width: $width; height: $height'></iframe>";
}
wp_embed_register_handler('umap', '#^https://umap.openstreetmap.de/[a-z]{2}/map/.*#', 'fscoli_embed_umap');
?>