Don
August 11, 2024, 9:20pm
1
Hello
These buttons are not active but appears under videos too.
Thanks
3 Likes
I can’t reproduce the issue, is this a specific filetype perhaps? I’ve tried MP4 and WebM with no luck
3 Likes
Don
August 13, 2024, 6:03pm
4
Hello Here is a sample video. It’s an MP4 video. I still see the buttons there…
Oh, Now I tried to upload a longer video and it seems it’s only appears to the short few sec one…
2 Likes
Don
August 13, 2024, 6:19pm
5
Hmm now just tried on more videos. Screen records etc. and seems only that video affects now on my side, strange. Probably it’s a result of some converting. But even then it’s not normal.
2 Likes
ah ha, this is kind of silly… but it’s because the video file name contains dimensions, this gets picked up by a function that is meant to append metadata to an image:
}
function isUpload(token) {
return token.content.includes("upload://");
}
function hasMetadata(token) {
return token.content.match(/(\d{1,4}x\d{1,4})/);
}
function appendMetaData(index, token) {
const sizePart = token.content
.split("|")
.find((x) => x.match(/\d{1,4}x\d{1,4}(,\s*\d{1,3}%)?/));
let selectedScale =
sizePart && sizePart.split(",").pop().trim().replace("%", "");
const overwriteScale = !SCALES.find((scale) => scale === selectedScale);
if (overwriteScale) {
selectedScale = "100";
}
and this metadata is used to determine if the controls should appear
3 Likes
Don
August 13, 2024, 6:50pm
7
Indeed Nice catch, I would never have realized that
![SampleVideo1mb|video](upload://7cZrskeouBoDXn3EruQR8mFS3gN.mp4)
![SampleVideo_1280x720_1mb|video](upload://7cZrskeouBoDXn3EruQR8mFS3gN.mp4)
1 Like
I’ve got a PR ready that will fix this soon:
discourse:main
← discourse:ux-video-controls
opened 07:14PM - 13 Aug 24 UTC
When adding a video/image/audio to a post, we check the token content for dimens… ions. If dimensions are found, we assume the content can be resized and give it image controls in the composer preview.
The problem is that we check the entire token, including filename, for dimensions. This means if a video has dimensions in its filename, we show broken controls:
![image](https://github.com/user-attachments/assets/93f3bbc9-1c0f-4ac3-b541-aab854624824)
This PR updates the `hasMetadata` function so it checks the area dedicated to dimensions specifically, which comes after the `|` in markdown.
Now images get the controls, and videos with dimensions in their filename do not:
![image](https://github.com/user-attachments/assets/92d64c52-f4d5-4ecc-9567-c0737f724ae7)
6 Likes