Easier Way To Add Youtube Video — an archived discussion from the APG vNext support community.
About This Topic
This thread covers easier way to add youtube video in the context of APG vNext, the ASP.NET forum and community platform. The community includes APG developers and experienced administrators who can help with similar questions.
APG vNext Support
- Knowledge Base — documented solutions
- FAQ — frequently asked questions
- Installation Guide
- Upgrade Guide
- Support Forum
Easy YouTube Video Embedding in APG vNext Posts
APG vNext supports YouTube video embedding in forum posts through two methods: the rich text editor's built-in media button, and auto-embed (automatically converting YouTube URLs into embedded players). Both methods produce a responsive iframe that works across desktop and mobile.
Method 1: Auto-Embed YouTube URLs
<!-- web.config: enable URL auto-embed -->
<add key="APG.Editor.AutoEmbedYouTube" value="true" />
<add key="APG.Editor.EmbedMaxWidth" value="720" />
<add key="APG.Editor.EmbedAspectRatio" value="16:9" />
When enabled, pasting a YouTube URL into the editor (e.g. https://youtube.com/watch?v=VIDEOID) automatically converts it to an embedded player on post save. The original URL is preserved in the database for portability.
Method 2: Insert via Editor Toolbar
- In the post editor, click the "Insert Media" button (film icon)
- Paste the YouTube URL
- Preview appears in the editor
- Post - the video appears inline in the thread
Responsive YouTube Embed CSS
.apg-video-embed {
position: relative;
width: 100%;
max-width: 720px;
aspect-ratio: 16 / 9;
margin: 1rem auto;
}
.apg-video-embed iframe {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border: 0;
border-radius: 8px;
}
Privacy-Enhanced YouTube Embed
<!-- Use youtube-nocookie.com to prevent YouTube tracking until play: -->
<add key="APG.Editor.YouTubeDomain" value="youtube-nocookie.com" />
Performance Considerations for Video Embeds
YouTube iframes load several hundred kilobytes of JavaScript and tracking scripts when the page renders, even before the member clicks play. This adds measurable page weight and can increase Largest Contentful Paint (LCP) metrics on thread pages with embedded videos. Use a facade/poster technique to defer iframe loading until the member explicitly clicks to play:
<!-- Lite YouTube Embed pattern (significantly faster): -->
<div class="apg-lite-yt" data-videoid="{YouTubeVideoID}">
<img src="https://i.ytimg.com/vi/{YouTubeVideoID}/hqdefault.jpg"
alt="Video thumbnail"
loading="lazy"
width="720" height="405" />
<button class="apg-yt-play" aria-label="Play video">
<svg><!-- play icon SVG --></svg>
</button>
</div>
<script>
document.querySelectorAll('.apg-lite-yt').forEach(el => {
el.addEventListener('click', function() {
const iframe = document.createElement('iframe');
iframe.src = `https://www.youtube-nocookie.com/embed/${this.dataset.videoid}?autoplay=1`;
iframe.allow = 'autoplay; encrypted-media';
iframe.allowFullscreen = true;
this.replaceWith(iframe);
});
});
</script>
This approach loads only a thumbnail image on initial page render and only creates the heavy YouTube iframe when the member explicitly clicks to watch. For threads with multiple embedded videos, this optimisation can reduce page weight by 1–2MB and improve LCP by 30–50%.
Managing Video Embeds in Moderation
Allow-listing domains for video embeds prevents members from embedding videos from untrusted sources that could contain inappropriate content or malware. Configure the allowed video domains in Admin Panel → Settings → Editor → Allowed Embed Domains. By default only YouTube and Vimeo are allowed. Add additional trusted domains (e.g., your company's video hosting at videos.yourcompany.com) as needed for your community's use case.
Embedding Videos from Self-Hosted Sources
For communities that host their own video content (training videos, product demos, conference recordings), APG vNext supports embedding from any source that provides an iframe embed code. Add a self-hosted video domain to the allowed embed list and use the editor's media button to paste the embed code directly. Self-hosted videos avoid YouTube's branding, recommendation algorithm that may direct members away from your forum after viewing, and the privacy tracking associated with YouTube cookies. For educational and enterprise communities, self-hosted video at a subdomain of your forum domain (e.g., videos.yourforum.com) is the most professional and privacy-compliant option.
Video Content Strategy for Forums
Video content significantly increases thread engagement — threads with embedded videos receive substantially more replies and views than text-only threads on comparable topics. Encourage moderators and power users to embed relevant video content in their posts, particularly for tutorials, demos, and event recordings. Create a dedicated forum category for video-centric content (e.g., a Tutorials or Show and Tell forum) that makes video content easily discoverable. Threads in this category with well-chosen thumbnail images display attractively in social sharing previews, increasing click-through from social media shares.
Moderating Video Content in Forum Posts
Video embeds in forum posts require moderator attention to ensure content appropriateness. APG vNext allows moderators to edit posts and remove embedded videos without deleting the entire post. The moderation queue can be configured to flag posts containing video embeds from certain domains for manual review before publishing, which is useful for forums where video content is less expected and potentially more likely to be inappropriate. Configure embed moderation rules in Admin Panel → Moderation → Content Filters → Embed Domains to define which domains require pre-publication review versus which are trusted for immediate publication.
Related Resources
Looking for more help? Browse the support forum or check the Knowledge Base.