mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-22 06:28:10 +02:00
feat: implement video thumbnail generation from Cloudinary URLs
This commit is contained in:
1 parent
58f513d476
commit
a35b9e3d1c
4 files changed
+101
-68
No files matched your search
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Derives a Cloudinary video thumbnail URL from the original video URL.
|
||||
*
|
||||
* Cloudinary automatically generates image frames for uploaded videos.
|
||||
* By inserting transformation parameters into the URL, we can extract
|
||||
* a static JPEG thumbnail without any backend change or DB migration.
|
||||
*
|
||||
* @param originalUrl - The Cloudinary video URL (e.g. .../video/upload/v123/file.mp4)
|
||||
* @returns A JPEG thumbnail URL with fill-crop at 400x400
|
||||
*/
|
||||
export function getVideoThumbnailUrl(originalUrl: string): string {
|
||||
// Only transform Cloudinary video URLs
|
||||
if (!originalUrl.includes('/video/upload/')) {
|
||||
return originalUrl;
|
||||
}
|
||||
|
||||
return originalUrl
|
||||
.replace('/video/upload/', '/video/upload/so_0,w_400,h_400,c_fill/')
|
||||
.replace(/\.[^.]+$/, '.jpg');
|
||||
}
|
||||
Reference in new issue
Block a user