如何在支持 Markdown 的文本字段中嵌入 YouTube 视频?
这是我尝试嵌入的代码:
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
有趣的是,此代码似乎在表单正下方的预览中显示嵌入的视频。保存表单后,代码片段将呈现为文本。
This is the code I'm trying to embed:
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jJECepNeCJ0&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
The interesting thing is that this code seems to display the embedded video in the Preview immediately below the form. Once the form is saved, the code snippet is rendered as text.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对我来说效果很好。
确保您的代码片段前面没有四个空格。
It works fine for me.
Make sure your code snippet doesn't have four spaces before it.
您可能必须扩展您正在使用的任何 Markdown 过滤器(假设 django.contrib.markup)以忽略
如果您在表单中使用某种 Javascript 编辑器,它可能会将 <<在将其保存到数据库之前,将其更改为
<
。在这种情况下,您可能需要更换编辑器。You're probably going to have to extend whatever markdown filter you're using (assuming django.contrib.markup) to ignore
<object>
tags.If you're using some sort of Javascript editor in your form, it may be converting the < to
<
before it is saved into your database. In this case, you may have to change the editor.