You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修改TinyMCE 4插入媒体时的默认尺寸(默认300x150)?

Hey there! Let's tackle that default MP4 size issue you're running into. The fix depends a bit on which platform or editor you're using, but here are the most common solutions to adjust that 300x150 default:

1. Check Editor Built-in Settings

Most visual editors (like WordPress's Gutenberg/Classic Editor, or other CMS media tools) have native settings for default media dimensions:

  • For WordPress, head to Settings > Media — look for sections labeled "Embed Content" or "Default Video Dimensions". You can directly input your preferred width and height here, then save the changes.
  • If you're using a third-party editor like TinyMCE, access its configuration panel and locate parameters like default_video_width and default_video_height to update the values.
2. Custom Code Snippet (For CMS Platforms Like WordPress)

If built-in settings don't work or you want more control, a small code snippet can override the default:

  • Open your theme's functions.php file (or use a code snippet plugin for safer edits) and add this code:
function custom_default_video_size($html, $url, $attr) {
    // Replace these values with your desired default dimensions
    $target_width = 800;
    $target_height = 450;
    
    // Only adjust if no custom dimensions are already set
    if (!isset($attr['width']) && !isset($attr['height'])) {
        $html = str_replace('width="300"', 'width="'.$target_width.'"', $html);
        $html = str_replace('height="150"', 'height="'.$target_height.'"', $html);
    }
    return $html;
}
add_filter('embed_oembed_html', 'custom_default_video_size', 10, 3);
  • Save the changes, and any new MP4 direct links you insert will use your specified default size.
3. Quick Manual Adjustment

For one-off video tweaks, you can edit the media's HTML directly after insertion:

  • Switch your editor to "Text/Code" mode, find the <video> or <iframe> tag for your MP4, and manually update the width and height attributes to your preferred values (e.g., width="800" height="450").

内容的提问来源于stack exchange,提问作者nexgen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:37:18