Commit 7c3040e2 authored by Jakob Moser's avatar Jakob Moser
Browse files

Merge branch 'add-umap-embed-support' into 'master'

Add umap embed support

Closes #19

See merge request !27
parents 7911604b 2215e41d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -32,4 +32,26 @@ 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 = esc_attr(
        is_numeric($embed_attrs['width']) ? $embed_attrs['width']."px" : "auto"
    );

    $height = esc_attr(
        is_numeric($embed_attrs['height']) ? $embed_attrs['height']."px" : "auto"
    );
    
    $url = esc_url($url);
    return <<<HTML
        <iframe src="$url" style="width: $width; height: $height" allow="fullscreen"></iframe>
    HTML;
}
wp_embed_register_handler('umap', '#^https://umap.openstreetmap.de/[a-z]{2}/map/[^/]*#', 'fscoli_embed_umap');
?>
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 * Author: personads :: Maximilian Müller-Eberstein (ursprüngliche Version und Design); Jakob Moser (Code-Rewrite)
 * Author URI: https://personads.me/
 *
 * Version: 1.7.0
 * Version: 1.8.0
 *
 * License: GNU General Public License v3.0
 * License URI: https://www.gnu.org/licenses/gpl-3.0.html