Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
989 views
in Plugins by
I just downloaded the Media Embed plugin and trying to embed a google map inside a question and an also in an answer  but i really cant understand how it works.

I tried to copy paste the google map url eg

https://www.google.gr/maps/place/%CE%9D%CE%B9%CE%BF%CF%85+%CE%A4%CE%B6%CE%AD%CF%81%CF%83%CE%B9,+%CE%97%CE%BD%CF%89%CE%BC%CE%AD%CE%BD%CE%B5%CF%82+%CE%A0%CE%BF%CE%BB%CE%B9%CF%84%CE%B5%CE%AF%CE%B5%CF%82/@40.1372315,-75.8522703,8z/data=!3m1!4b1!4m5!3m4!1s0x89c0fb959e00409f:0x2cd27b07f83f6d8d!8m2!3d40.0583238!4d-74.4056612

and even the iframe embed code like that:

<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d1561716.1218456167!2d-75.85227027693055!3d40.137231460220384!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c0fb959e00409f%3A0x2cd27b07f83f6d8d!2zzp3Ouc6_z4UgzqTOts6tz4HPg865LCDOl869z4nOvM6tzr3Otc-CIM6gzr_Ou865z4TOtc6vzrXPgg!5e0!3m2!1sel!2sgr!4v1500493661219" width="600" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

But both doesnt embed the map inside the question or answer field. Is the plugin code for google maps embed outdated or what i m doing wrong ?
Q2A version: 1.7.4
by
@scott @sama55 i need your help !

2 Answers

+1 vote
by

Gmap will be shown correctly on the custom page with "Admin">"Pages">"Add Page". The reason is that contents of the custom page is shown as it is without being sanitized for security. On the other hand, posts are sanitized by HTMLawed just before being shown. HTMLawed does not allow "iframe" tag by default. Look at qa-include/qa-base.php::qa_sanitize_html(). Below thread will be useful.

http://www.question2answer.org/qa/38943

My CKEditor plugin is unnecessary. You will be able to deal with core hacking or overriding qa_sanitize_html() function.

  • 8.1 Easy solution (for Q2A beginner)
  • 8.2 Expert solution (for Q2A engineer / designer / etc)

Point:

//'elements' => '*+embed+object-form',
'elements' => '*+embed+object+iframe-form',

Caution:

If you allow iframe, your site will be vulnerable relatively. It is important that registered users are trustworthy people.

by
i think she is talking about this plugin http://www.q2apro.com/plugins/embed and not a custom page @sama55
by
moved by
@sama55 i mean how can i embed a google map using the PLUGIN "media embed" ! i already installed the plugin but it doesnt embed the google map inside the question. (or answer).

Thanks
+2 votes
by

OK. Probably, the cause is this. This plugin is very old. So there will be many other problems.

by
Hi @sama55 and thanks for your replies. After a lot of research i succeeded  to display the gmaps iframe without the map inside and i am getting this console error.

"Load denied by X-Frame-Options: https://www.google.gr/maps/@xxxxxxx does not permit cross-origin framing"

Any idea about this ?
by
Example of embed code:
https://maps.google.com/maps/embed?pb=!1m14!1m8!1m3!1d1561716.1209313665!2d-75.8522703!3d40.1372315!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x89c0fb959e00409f%3A0x2cd27b07f83f6d8d!2z44Ki44Oh44Oq44Kr5ZCI6KGG5Zu9IOODi-ODpeODvOODu-OCuOODo-ODvOOCuOODvOW3ng!5e0!3m2!1sja!2sgr!4v1500593420731

However, in this case "View Larger Map" will become error.
The Google Maps Embed API must be used in an iframe.

Fix plugin:
'gmap'=>array(
    array(
        //'(https*:\/\/maps.google.com\/?[^< ]+)',
        //'<iframe width="'.qa_opt('embed_gmap_width').'" height="'.qa_opt('embed_gmap_height').'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="$1&amp;ie=UTF8&amp;output=embed"></iframe><br /><small><a href="$1&amp;ie=UTF8&amp;output=embed" style="color:#0000FF;text-align:left">View Larger Map</a></small>','gmap'
        '(https*:\/\/maps.google.\/?[^< ]+)',
        '<iframe width="'.qa_opt('embed_gmap_width').'" height="'.qa_opt('embed_gmap_height').'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="$1&amp;ie=UTF8"></iframe>','gmap'
    )
),
...