SMF 2.0 RC3: Flickr HTML code to BBCode mod [working]
We are developing a photographic website (with an SMF 2.0 RC3 forum) and most of our users have their photos hosted in Flickr.
(Note: I have installed WYSIWYG Quick Reply v2 RC3 package)
So I’d like to make their lifes easier when sharing their photos by adding a custom button (here in the post wysiwyg editor) which converts this html structure (the code snippet flickr shows to the user):
<a href="URL1" title="this_is_the_title"><img src="IMGURL" width="342" height="500" alt="alt_text" /></a>
To something like:
[url=URL1][img]IMGURL[/img][/url]
How to do this?
* Edit your Themes/default/GenericControls.template.php
* Locate:
function template_control_richedit($editor_id, $smileyContainer = null, $bbcContainer = null) { global $context, $settings, $options, $txt, $modSettings, $scripturl; $editor_context = &$context['controls']['richedit'][$editor_id];
* Add after:
?>
<script language="javascript">
function convierteCode(){
// dado un codigo tipo flickr lo convierte a BBCode (def en GenericControls.template.php)
var flickr = document.getElementById("flickrcodeinput").value;
flickr = flickr.replace('<a href="','[url=');
flickr = flickr.replace('" /></a>','[/img][/url]');
flickr = flickr.replace(/"(.)+title(.)*><img(.)+src="/,'][img]');
flickr = flickr.replace(/"(.)+width(.)*\[/,'[');
flickr = flickr.replace('[/url]','[/img][/url]');
document.getElementById("message").value += flickr;
window.frames[0].document.write(flickr);
}
</script>
<?php*Locate:
echo ' <div> <div> <textarea class="editor"
* Replace with:
echo ' <div> <div> <!-- flickr input and button--> <input type="text" id="flickrcodeinput" width="100px"></input> <input type="button" value="Inserta IMG flickr" onClick="convierteCode();"></input> <br /><br /> <!--flickr input and button end --> <textarea class="editor"
* Upload the new GenericControls.template.php
(Note for curious people: I also tried this by adding a custom button which would produce a new bbcode like [flickr][/flickr] and blahblahblah, but I could not make it work. More details here)
Related posts:
Encontré tu blog buscando específicamente esto. Misma situació: un blog SMF de fotografía, con usuarios usando Flickr. Lo intente, pero sin éxito.