יחידה:EmbedMedia – הבדלי גרסאות
יצירת דף עם התוכן "-- Module:EmbedMedia - גרסה מקיפה local p = {} function p.embed(frame) local url = frame.args.url or frame.args[1] local width = frame.args.width or "100%" local height = frame.args.height or "315" local autoplay = frame.args.autoplay == "true" and 1 or 0 local loop = frame.args.loop == "true" and 1 or 0 local muted = frame.args.muted == "true" and 1 or 0 if not url or url == "" then return '<span style="color:..." תגיות: עריכה ממכשיר נייד עריכה דרך האתר הנייד עריכה מתקדמת מהנייד |
אין תקציר עריכה תגיות: עריכה ממכשיר נייד עריכה דרך האתר הנייד עריכה מתקדמת מהנייד |
||
| שורה 1: | שורה 1: | ||
local p = {} | local p = {} | ||
| שורה 5: | שורה 4: | ||
local url = frame.args.url or frame.args[1] | local url = frame.args.url or frame.args[1] | ||
local width = frame.args.width or "100%" | local width = frame.args.width or "100%" | ||
local height = frame.args.height or " | local height = frame.args.height or "360" | ||
local autoplay = frame.args.autoplay == "true" and | local autoplay = frame.args.autoplay == "true" and "autoplay" or "" | ||
local loop = frame.args.loop == "true" and | local loop = frame.args.loop == "true" and "loop" or "" | ||
local muted = frame.args.muted == "true" and | local muted = frame.args.muted == "true" and "muted" or "" | ||
if not url or url == "" then | if not url or url == "" then | ||
return '<span style="color:red;">שגיאה: לא סופק קישור למדיה</span>' | return '<span style="color:red;">שגיאה: לא סופק קישור למדיה</span>' | ||
end | end | ||
-- YouTube | -- YouTube | ||
local yt_id = url:match("v=([%w%-_]+)") or url:match("youtu%.be/([%w%-_]+)") | local yt_id = url:match("v=([%w%-_]+)") or url:match("youtu%.be/([%w%-_]+)") | ||
if yt_id then | if yt_id then | ||
local | local embed_url = "https://www.youtube.com/embed/"..yt_id | ||
return string.format('<iframe width="%s" height="%s" src="%s" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>', width, height, embed_url) | |||
end | end | ||
| שורה 26: | שורה 23: | ||
local vimeo_id = url:match("vimeo.com/(%d+)") | local vimeo_id = url:match("vimeo.com/(%d+)") | ||
if vimeo_id then | if vimeo_id then | ||
local | local embed_url = "https://player.vimeo.com/video/"..vimeo_id | ||
return string.format('<iframe width="%s" height="%s" src="%s" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>', width, height, embed_url) | |||
end | end | ||
-- | -- MP4 | ||
if url:match("%.mp4$") then | |||
return string.format('<video width="%s" height="%s" controls %s %s %s><source src="%s" type="video/mp4">דפדפן זה אינו תומך בהטמעת וידאו.</video>', width, height, autoplay, loop, muted, url) | |||
end | end | ||
-- | -- MP3 | ||
if | if url:match("%.mp3$") then | ||
return string.format( | return string.format('<audio controls %s %s %s><source src="%s" type="audio/mpeg">דפדפן זה אינו תומך בהטמעת שמע.</audio>', autoplay, loop, muted, url) | ||
end | end | ||
-- SoundCloud | -- SoundCloud (צריך iframe) | ||
if | if url:match("soundcloud.com") then | ||
return string.format('<iframe width=" | return string.format('<iframe width="%s" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=%s"></iframe>', width, url) | ||
end | end | ||
return '<span style="color:red;">שגיאה: סוג מדיה לא נתמך</span>' | |||
end | end | ||
return p | return p | ||