Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-video-processor-1.0.js

Код файла
Версия от 09.10.2026, 07:01:06 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
301	video.style.top = '0';302	video.style.left = '0';303	video.style.minHeight = '100%';304	video.style.minWidth = '100%';305	video.style.height = options.height + 'px';306	video.style.width = options.width + 'px';307	video.style.objectFit = 'cover';308	video.autoplay = options.autoplay;309	video.loop = options.loop;310	video.muted = options.muted;311	video.volume = options.volume;312	video.setAttribute('playsinline', '');
История файла и сравнение версий
  • 09.10.2026, 07:01:06 · 56c3b845
313
314 video.addEventListener('canplay', function () {
315 if (options.autoplay) {
316 video.muted = true;
317 video.play();
318 }
319 });
320
321 var codec = options.mp4 ? 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"' : 'video/webm; codecs="vp8, vorbis"';
322 var emptyVideo = document.createElement('video');
323 var isVideoSupported = emptyVideo.canPlayType(codec);
324
325 if (isVideoSupported) {
326 video.src = options.webm || options.mp4;
327 videoWrapper.insertAdjacentElement('beforeend', video);
328 } else if (!videoWrapper.querySelector('.no-video-loader')) {
329 // image for those that don't support the video
330 var img = document.createElement('img');
331 img.setAttribute('src', options.poster);
332 img.style.position = 'absolute';
333 img.style.zIndex = options.zIndex;
334 img.style.top = '0';
335 img.style.left = '0';
336 img.style.minHeight = '100%';
337 img.style.minWidth = '100%';
338 img.classList.add('no-video-loader');
339 videoWrapper.insertAdjacentElement('beforeend', img);
340 }
341
342 return videoWrapper;
343}
344
345/**
346 * set width and height to current video.
347 * Naming without prefix, because used in blocks.
348 *
349 * @param {HTMLElement} el - current el
350 * @param {string} height - height with px or vh
351 * @param {string} type - YouTube or HTML5 video
352 */
353function setWidthAndHeightVideo(el, height, type) {
354 var iframe = el.querySelector('iframe');
355 var coverCarrier = el.closest('.t-cover__carrier');
356 if (type === 'html5') {
357 var video = el;
358 el = el.closest('.t-cover__carrier');
359 iframe = el.querySelector('video');
360 }
361
362 var isHasCover = el.getAttribute('data-content-video-nocover') !== 'yes';
363 var isAdCutted = el.getAttribute('data-content-video-noadcut-youtube') !== 'yes';
364 var isAdCuttedInType = type === 'youtube' || type === 'rutube' || type === 'vk';
365 var customRatio = el.getAttribute('data-content-video-ratio');
366 var adCuttedPadding = isAdCutted && isAdCuttedInType ? 220 : 0;
367 var videoRatio = 0.5625;
368
369 if (customRatio && parseFloat(customRatio) > 0) videoRatio = parseFloat(customRatio);
370
371 if (isHasCover) {
372 var coverHeight = t_videoprocessor__getHeight(height, isHasCover, el, videoRatio);
373 var videoWidth = coverCarrier?.clientWidth || window.innerWidth;
374 var videoHeight = videoWidth * videoRatio;
375 var deltaRatio = 1;
376
377 // recalculate deltaRatio if video height less than div height
378 if (videoHeight - adCuttedPadding < coverHeight) {
379 deltaRatio = videoHeight < coverHeight ? coverHeight / videoHeight : videoHeight / coverHeight;
380 deltaRatio += 0.02;
381 }
382
383 var zoomedWidth = Math.floor(videoWidth * deltaRatio);
384 var zoomedHeight = Math.floor((videoHeight + adCuttedPadding) * deltaRatio);
385 var heightDelta = zoomedHeight - coverHeight;
386 var widthDelta = zoomedWidth - videoWidth;
387
388 if (iframe) iframe.style.height = zoomedHeight + 'px';
389 if (iframe) iframe.style.width = zoomedWidth + 'px';
390
391 if (type === 'html5' && video) {
392 video.style.height = coverHeight + 'px';
393 video.style.width = videoWidth + 'px';
394 }
395
396 if (iframe) iframe.style.marginTop = heightDelta > 0 ? -Math.floor(heightDelta / 2) + 'px' : '0';
397 if (iframe) iframe.style.marginLeft = widthDelta > 0 ? -Math.floor(widthDelta / 2) + 'px' : '0';
398 } else {
399 var noCoverHeight = t_videoprocessor__getHeight(height, isHasCover, el, videoRatio);
400 if (type === 'html5' && video) {
Предыдущие 100 строкСледующие 100 строк