(☞ຈل͜ຈ)☞ Главная  Статьи  Загрузчик Домой

Ok!
Ok!
96
function resizeAndConvertImageWebP(
    $width,
    $height,
    $density,
    $originalFilepath,
    $resizedFilepath) {
  $newWidth = $width * $density;
  $newHeight = $height * $density;

  $image = new Imagick($originalFilepath);
  $origImageDimens = $image->getImageGeometry();
  $origImgWidth = $origImageDimens['width'];
  $origImgHeight = $origImageDimens['height'];

  if($newWidth == 0) {
    $ratioOfHeight = $newHeight / $origImgHeight;
    $newWidth = $origImgWidth * $ratioOfHeight;
  }

  if($newHeight == 0) {
    $ratioOfWidth = $newWidth / $origImgWidth;
    $newHeight = $origImgHeight * $ratioOfWidth;
  }

  $widthRatios = $origImgWidth / $newWidth;
  $heightRatios = $origImgHeight / $newHeight;

  if($widthRatios <= $heightRatios) {
    $cropWidth = $origImgWidth;
    $cropHeight = $newWidth * $widthRatios;
  } else {
    $cropWidth = $newHeight * $heightRatios;
    $cropHeight = $origImgHeight;
  }

  $cropX = ($origImgWidth - $cropWidth) / 2;
  $cropY = ($origImgHeight - $cropHeight) / 2;

  $image->stripImage();
  $image->cropImage($cropWidth, $cropHeight, $cropX, $cropY);
  $image->resizeImage($newWidth, $newHeight, imagick::FILTER_LANCZOS, 0.9);
  $image->setImageFormat('webp');
  $image->setImageAlphaChannel(imagick::ALPHACHANNEL_ACTIVATE);
  $image->setBackgroundColor(new ImagickPixel('transparent'));
  $image->writeImage($resizedFilepath);
}
webp,support,imagemagic140Конвертация картинки в webp в случае, если imageMagic поддрживает
95
<?=(webps() && is_file($_SERVER['DOCUMENT_ROOT'] . str_replace('.jpg', '.webp', $arItem["DETAIL_PICTURE"]["SRC"])))?'style="background-image: url('.str_replace('.jpg', '.webp', $arItem["DETAIL_PICTURE"]["SRC"]).')':'style="background-image: url('.$arItem["DETAIL_PICTURE"]["SRC"].')'?>"
webp,support120Бэкграунд если готов файл webp
94
$webpsupport = (strpos($_SERVER['HTTP_ACCEPT'], 'image/webp') >= 0);
if($webpsupport) {
  $this->attemptToServeWebP($pathinfo, $matches, $width, $height, $density);
} else {
  $this->attemptToServeNormal($pathinfo, $matches, $width, $height, $density);
}
webp,support100Определить, поддерживает ли браузер webp картинки
93
<?=($this->GetFolder().'/images/ .... ?>
картинка шаблона инфоблока3200Путь картинки из папки images размещенной в шаблоне компонента
92
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$path = $protocol . $_SERVER['HTTP_HOST'] . SITE_TEMPLATE_PATH;
битрикс, путь1450Путь до файла без слеша на конце
91
При ошибке 502 в импорте инфоблоков Битрикс
Заменить в файле
/bitrix/modules/iblock/admin/iblock_xml_import.php

if($obXMLFile->ReadXMLToDatabase($fp, $NS, $INTERVAL))
на
if($obXMLFile->ReadXMLToDatabase($fp, $NS, 10, $INTERVAL))
502, битрикс, инфоблок, ошибка импорта140Ошибка импорта инфоблока Битрикс 502
90
center iframe {
    width: 100%;
    height: calc(100vw * 9 / 16 );
}
iframe, youtube, height120Установить размер iframe видео с Youtube, подогнать его под мобильный размер. При условии, что видео 100% ширны.
89
$post = get_post();
$t = strtotime($post->post_modified_gmt);
$str = 'Last-Modified: '.gmdate('D, d M Y H:i:s', $t).' GMT';
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $t).' GMT');
daremodified, wp, php1200WP date modified php file
88
document.addEventListener("DOMContentLoaded", function(event) {
    var cl = document.getElementById('#all_otz');
    cl.onclick = function(ev) {
        var post = {};
        post['num_otz'] = 20;
        post['ajax'] = 'y';
        node = BX('video_feed_block');
        if (!!node) {
            BX.ajax.post(
                'https://www.brtclinic.ru/index.php',
                post,
                function (data) {
                    var el = data.getElementById('video_feed_block');
                    node.innerHTML = el.innerHTML();
                }
            );

        }
    }
});
битрикс, битрикс аякс1090Битрикс функция вместо jQuery ajax
87
var setResponsive = function () {
  if ($(window).height() > $("#adminmenuwrap").height() + 50) {
     $('#adminmenuwrap').css('position', 'fixed'); 
  } else {
     $('#adminmenuwrap').css('position', 'relative'); 
  }
}
$(window).resize(setResponsive);
setResponsive();
wp, overflow, height500Функция WP для отображения кнопок левого меню админки пр низком экране
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27