[wp-hackers] Problem with custom TinyMCE button

Karl Wångstedt kalle at wangstedt.net
Thu Feb 5 10:29:53 GMT 2009


Hi all

I'm not sure this is the right forum for this question. I've tried to  
get answers from elsewhere, but without any luck. So I turn to you,  
guys as I consider you the crème de la crème of the WP community.

I'm building an update to a site, and have decided to use xHTML5 to  
make use of the new <video> element. It doesn't really matter that I  
use xHTML5, the same happens if I use an <embed> or something else.

The idea of the plugin is to take the inserted link from the gallery- 
box, extract the link-URI and insert the new element with the link in  
the right place.

On my developing server I've used WP2.6.3, and now when it's time to  
release the site, I've upgraded to WP2.7.

But when I did that, I ran in to a problem with a custom TinyMCE  
button that I've built. The button is supposed to take a link to a  
video file (<a href="video.mov">) and convert it to a <video> element  
with the link intact inside it. The button works fine in 2.6, but in  
2.7 it removes the link from the editor and nothing gets inserted but  
a <span style="color: #000099; text-decoration: underline;"> </span>.

I'd really appreciate if someone could point me in the right direction.

The code for the button is:

			// Register button
			ed.addButton('videolink', {
				title : 'videolink.desc',
				image : url + '/img/videolink.gif',
				onclick : function() {
					// Add you own code to execute something on click
					
					var kewvalue = ed.selection.getContent({format : 'text'}); // Get  
the selected text
					var e = ed.dom.getParent(ed.selection.getNode(), 'A'); // Get the  
link
					var kewuri = ed.dom.getAttrib(e, 'href'); // The URL from the link
					// Add new code to replace the selected text
					ed.selection.setContent('<p class="align02"><video src="'+kewuri 
+'" controls="true"><a href="'+kewuri+'">'+kewvalue+'</a></video></p>');
				}
			});

Thank you
Karl Wångstedt

----------------------------------
         Wångstedt  nova
        www.wangstedt.net

Karl Wångstedt       0278-61 12 33
Stenhuggarvägen 3g   070-578 13 04
821 41  BOLLNÄS
----------------------------------
Det här brevet skickades med en Macintosh från Apple.
Garanterat virusfri med Mac OS X.


More information about the wp-hackers mailing list