如何修改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_widthanddefault_video_heightto 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.phpfile (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 thewidthandheightattributes to your preferred values (e.g.,width="800" height="450").
内容的提问来源于stack exchange,提问作者nexgen
相关产品推荐
相关产品推荐

