Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Не понятные фоны у фото карточек товара и категорий


shweder
 Поделиться

Рекомендованные сообщения

Добрый день,

вот такая проблема,  рандомный желто-черно-белый фон  https://prnt.sc/G5u0On1f_auG

 

как его заменить на белый? сам файл этого фона найти не получается 

 

сам сайт https://clck.ru/dVjaZ

Ссылка на комментарий
Поделиться на других сайтах


01.03.2022 в 14:15, shweder сказал:

как его заменить на белый? сам файл этого фона найти не получается 

сам сайт указал не правильно, в общем вот https://mir-slv.ru/

 

файла данного фона нет, смотрите как у вас в контроллере обрезаются картинки, если у вас обрезаются картинки методом

$this->model_tool_image->resize

то нужно его править. в общем информации не достаточно, может у вас какой то модификатор это делает или модуль. 

В общем нужно смотреть вашу админку и ваши файлы

Ссылка на комментарий
Поделиться на других сайтах

01.03.2022 в 11:15, shweder сказал:

Добрый день,

вот такая проблема,  рандомный желто-черно-белый фон  https://prnt.sc/G5u0On1f_auG

 

как его заменить на белый? сам файл этого фона найти не получается 

 

сам сайт https://clck.ru/dVjaZ

Для начала.
В контроллерах изображения обрабатываются такой функцией
$image = $this->model_tool_image->resize(
Посмотрите, что у вас. В файлах измененных модификаторами прежде всего.

Ссылка на комментарий
Поделиться на других сайтах

у меня там вот такая история 

Скрытый текст

foreach ($results as $result) {
                if ($result['image']) {
                    $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));
                } else {
                    $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));

 

Ссылка на комментарий
Поделиться на других сайтах


01.03.2022 в 19:40, shweder сказал:

у меня там вот такая история 

  Скрыть содержимое

foreach ($results as $result) {
                if ($result['image']) {
                    $image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));
                } else {
                    $image = $this->model_tool_image->resize('placeholder.png', $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height'));

 

 

значит надо идти в метод model_tool_image и смотреть что там да как

Ссылка на комментарий
Поделиться на других сайтах

01.03.2022 в 18:56, Venter сказал:

 

значит надо идти в метод model_tool_image и смотреть что там да как

 там у меня такая история 

Скрытый текст

<?php
class ModelToolImage extends Model {
    public function resize($filename, $width, $height) {
        if (!is_file(DIR_IMAGE . $filename)) {
            if (is_file(DIR_IMAGE . 'no_image.jpg')) {
                $filename = 'no_image.jpg';
            } elseif (is_file(DIR_IMAGE . 'no_image.png')) {
                $filename = 'no_image.png';
            } else {
                return;
            }
        }

        $extension = pathinfo($filename, PATHINFO_EXTENSION);

        $image_old = $filename;
        $image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

        if (!is_file(DIR_IMAGE . $image_new) || (filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new))) {
            list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);

            if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
                return DIR_IMAGE . $image_old;
            }

            $path = '';

            $directories = explode('/', dirname($image_new));

            foreach ($directories as $directory) {
                $path = $path . '/' . $directory;

                if (!is_dir(DIR_IMAGE . $path)) {
                    @mkdir(DIR_IMAGE . $path, 0777);
                }
            }

            if ($width_orig != $width || $height_orig != $height) {
                $image = new Image(DIR_IMAGE . $image_old);
                $image->resize($width, $height);
                $image->save(DIR_IMAGE . $image_new);
            } else {
                copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
            }
        }

        $imagepath_parts = explode('/', $image_new);
        $new_image = implode('/', array_map('rawurlencode', $imagepath_parts));

        if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
            return $this->config->get('config_ssl') . 'image/' . $new_image;
        } else {
            return $this->config->get('config_url') . 'image/' . $new_image;
        }
    }
}
 

 

Ссылка на комментарий
Поделиться на других сайтах


01.03.2022 в 20:48, shweder сказал:

 там у меня такая история 

  Скрыть содержимое

<?php
class ModelToolImage extends Model {
    public function resize($filename, $width, $height) {
        if (!is_file(DIR_IMAGE . $filename)) {
            if (is_file(DIR_IMAGE . 'no_image.jpg')) {
                $filename = 'no_image.jpg';
            } elseif (is_file(DIR_IMAGE . 'no_image.png')) {
                $filename = 'no_image.png';
            } else {
                return;
            }
        }

        $extension = pathinfo($filename, PATHINFO_EXTENSION);

        $image_old = $filename;
        $image_new = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . (int)$width . 'x' . (int)$height . '.' . $extension;

        if (!is_file(DIR_IMAGE . $image_new) || (filectime(DIR_IMAGE . $image_old) > filectime(DIR_IMAGE . $image_new))) {
            list($width_orig, $height_orig, $image_type) = getimagesize(DIR_IMAGE . $image_old);

            if (!in_array($image_type, array(IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF))) {
                return DIR_IMAGE . $image_old;
            }

            $path = '';

            $directories = explode('/', dirname($image_new));

            foreach ($directories as $directory) {
                $path = $path . '/' . $directory;

                if (!is_dir(DIR_IMAGE . $path)) {
                    @mkdir(DIR_IMAGE . $path, 0777);
                }
            }

            if ($width_orig != $width || $height_orig != $height) {
                $image = new Image(DIR_IMAGE . $image_old);
                $image->resize($width, $height);
                $image->save(DIR_IMAGE . $image_new);
            } else {
                copy(DIR_IMAGE . $image_old, DIR_IMAGE . $image_new);
            }
        }

        $imagepath_parts = explode('/', $image_new);
        $new_image = implode('/', array_map('rawurlencode', $imagepath_parts));

        if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
            return $this->config->get('config_ssl') . 'image/' . $new_image;
        } else {
            return $this->config->get('config_url') . 'image/' . $new_image;
        }
    }
}
 

 

 

Покажите файл system/library/image.php

Ссылка на комментарий
Поделиться на других сайтах

01.03.2022 в 21:15, Venter сказал:

 

Покажите файл system/library/image.php

 

пожалуйста, друг 

Скрытый текст
Скрытый текст

<?php
class Image {
    private $file;
    private $image;
    private $width;
    private $height;
    private $bits;
    private $mime;

    public function __construct($file) {
        if (file_exists($file)) {
            $this->file = $file;

            $info = getimagesize($file);

            $this->width  = $info[0];
            $this->height = $info[1];
            $this->bits = isset($info['bits']) ? $info['bits'] : '';
            $this->mime = isset($info['mime']) ? $info['mime'] : '';

            if ($this->mime == 'image/gif') {
                $this->image = imagecreatefromgif($file);
            } elseif ($this->mime == 'image/png') {
                $this->image = imagecreatefrompng($file);
            } elseif ($this->mime == 'image/jpeg') {
                $this->image = imagecreatefromjpeg($file);
            }
        } else {
            exit('Error: Could not load image ' . $file . '!');
        }
    }

    public function getFile() {
        return $this->file;
    }

    public function getImage() {
        return $this->image;
    }

    public function getWidth() {
        return $this->width;
    }

    public function getHeight() {
        return $this->height;
    }

    public function getBits() {
        return $this->bits;
    }

    public function getMime() {
        return $this->mime;
    }

    public function save($file, $quality = 90) {
        $info = pathinfo($file);

        $extension = strtolower($info['extension']);
$extension = 'png';
        if (is_resource($this->image)) {
            if ($extension == 'jpeg' || $extension == 'jpg') {
                imagejpeg($this->image, $file, $quality);
            } elseif ($extension == 'png') {
                imagepng($this->image, $file);
            } elseif ($extension == 'gif') {
                imagegif($this->image, $file);
            }

            imagedestroy($this->image);
        }
    }

    public function resize($width = 0, $height = 0, $default = '') {
        if (!$this->width || !$this->height) {
            return;
        }

        $xpos = 0;
        $ypos = 0;
        $scale = 1;

        $scale_w = $width / $this->width;
        $scale_h = $height / $this->height;

        if ($default == 'w') {
            $scale = $scale_w;
        } elseif ($default == 'h') {
            $scale = $scale_h;
        } else {
            $scale = min($scale_w, $scale_h);
        }

        if ($scale == 1 && $scale_h == $scale_w && $this->mime != 'image/png') {
            return;
        }

        $new_width = (int)($this->width * $scale);
        $new_height = (int)($this->height * $scale);
        $xpos = (int)(($width - $new_width) / 2);
        $ypos = (int)(($height - $new_height) / 2);

        $image_old = $this->image;
        $this->image = imagecreatetruecolor($width, $height);

        if ($this->mime == 'image/png') {
            imagealphablending($this->image, false);
            imagesavealpha($this->image, true);
            $background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
            imagecolortransparent($this->image, $background);
        } else {
            $background = imagecolorallocate($this->image, 255, 255, 0);
        }

        imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
imagecolortransparent($this->image,$background);
        imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->width, $this->height);
        imagedestroy($image_old);

        $this->width = $width;
        $this->height = $height;
    }

    public function watermark($watermark, $position = 'bottomright') {
        switch($position) {
            case 'topleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = 0;
                break;
            case 'topcenter':
                $watermark_pos_x = intval(($this->width - $watermark->getWidth()) / 2);
                $watermark_pos_y = 0;
                break;
            case 'topright':
                $watermark_pos_x = $this->width - $watermark->getWidth();
                $watermark_pos_y = 0;
                break;
            case 'middleleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = intval(($this->height - $watermark->getHeight()) / 2);
                break;
            case 'middlecenter':
                $watermark_pos_x = intval(($this->width - $watermark->getWidth()) / 2);
                $watermark_pos_y = intval(($this->height - $watermark->getHeight()) / 2);
                break;
            case 'middleright':
                $watermark_pos_x = $this->width - $watermark->getWidth();
                $watermark_pos_y = intval(($this->height - $watermark->getHeight()) / 2);
                break;
            case 'bottomleft':
                $watermark_pos_x = 0;
                $watermark_pos_y = $this->height - $watermark->getHeight();
                break;
            case 'bottomcenter':
                $watermark_pos_x = intval(($this->width - $watermark->getWidth()) / 2);
                $watermark_pos_y = $this->height - $watermark->getHeight();
                break;
            case 'bottomright':
                $watermark_pos_x = $this->width - $watermark->getWidth();
                $watermark_pos_y = $this->height - $watermark->getHeight();
                break;
        }
        
        imagealphablending( $this->image, true );
        imagesavealpha( $this->image, true );
        imagecopy($this->image, $watermark->getImage(), $watermark_pos_x, $watermark_pos_y, 0, 0, $watermark->getWidth(), $watermark->getHeight());

        imagedestroy($watermark->getImage());
    }

    public function crop($top_x, $top_y, $bottom_x, $bottom_y) {
        $image_old = $this->image;
        $this->image = imagecreatetruecolor($bottom_x - $top_x, $bottom_y - $top_y);

        imagecopy($this->image, $image_old, 0, 0, $top_x, $top_y, $this->width, $this->height);
        imagedestroy($image_old);

        $this->width = $bottom_x - $top_x;
        $this->height = $bottom_y - $top_y;
    }

    public function rotate($degree, $color = 'FFFFFF') {
        $rgb = $this->html2rgb($color);

        $this->image = imagerotate($this->image, $degree, imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2]));

        $this->width = imagesx($this->image);
        $this->height = imagesy($this->image);
    }

    private function filter() {
        $args = func_get_args();

        call_user_func_array('imagefilter', $args);
    }

    private function text($text, $x = 0, $y = 0, $size = 5, $color = '000000') {
        $rgb = $this->html2rgb($color);

        imagestring($this->image, $size, $x, $y, $text, imagecolorallocate($this->image, $rgb[0], $rgb[1], $rgb[2]));
    }

    private function merge($merge, $x = 0, $y = 0, $opacity = 100) {
        imagecopymerge($this->image, $merge->getImage(), $x, $y, 0, 0, $merge->getWidth(), $merge->getHeight(), $opacity);
    }

    private function html2rgb($color) {
        if ($color[0] == '#') {
            $color = substr($color, 1);
        }

        if (strlen($color) == 6) {
            list($r, $g, $b) = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
        } elseif (strlen($color) == 3) {
            list($r, $g, $b) = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
        } else {
            return false;
        }

        $r = hexdec($r);
        $g = hexdec($g);
        $b = hexdec($b);

        return array($r, $g, $b);
    }
}
 

 

 

Ссылка на комментарий
Поделиться на других сайтах


02.03.2022 в 14:15, shweder сказал:

$background = imagecolorallocate($this->image, 255, 255, 0);

попробуйте вот эту строку заменить на это

$background = imagecolorallocate($this->image, 255, 255, 255);

 

Ссылка на комментарий
Поделиться на других сайтах

02.03.2022 в 13:56, Venter сказал:

попробуйте вот эту строку заменить на это

$background = imagecolorallocate($this->image, 255, 255, 255);

 

заменил, ну как я понимаю сейчас для теста мне нужно новые картинки подгружать, все старые фото не с этим жёлтым фоном не изенятся 

Ссылка на комментарий
Поделиться на других сайтах


02.03.2022 в 19:31, shweder сказал:

заменил, ну как я понимаю сейчас для теста мне нужно новые картинки подгружать, все старые фото не с этим жёлтым фоном не изенятся 

Надо обновить модификаторы и очистить весь кеш картинок на сайте

Ссылка на комментарий
Поделиться на других сайтах

02.03.2022 в 19:19, Venter сказал:

Надо обновить модификаторы и очистить весь кеш картинок на сайте

сделал, но старые фото ка кбыли так и остались

Ссылка на комментарий
Поделиться на других сайтах


02.03.2022 в 20:45, shweder сказал:

сделал, но старые фото ка кбыли так и остались

старые фото это кеш. я что выше написал??? ОЧИСТИТЬ ВЕСЬ КЕШ КАРТИНОК!!!! то есть взять и удалить старые или придется по новой добавлять картинки, так как ресайз сразу обрезает до нужного размера и сохраняет картинку. В общем думайте как лучше

Ссылка на комментарий
Поделиться на других сайтах

@shweder , проблемы с фоном способен решить этот модуль:

 

 

 

Мой модуль учитывает всевозможные нештатные ситуации и неправильные картинки. Вплоть до битых и не до конца загруженных картинок.

Например, когда внутри изображения JPEG находится PNG.

Или вместо файла для WEB ( в кодировке RGB) используются файлы для типографии (4-х канальный типографский цвет).

Умеет правильно корректировать фон и избавляться от эффекта "внезапного появления черного фона".

А также много других факторов.

 

Пишите в личку или лучше на почту. Думаю, что смогу вам помочь.

Ссылка на комментарий
Поделиться на других сайтах

02.03.2022 в 21:40, Venter сказал:

старые фото это кеш. я что выше написал??? ОЧИСТИТЬ ВЕСЬ КЕШ КАРТИНОК!!!! то есть взять и удалить старые или придется по новой добавлять картинки, так как ресайз сразу обрезает до нужного размера и сохраняет картинку. В общем думайте как лучше

 

отчистил весь кеш,  ситауция сдвинулась с места

желтые полоски ушли, но теперь есть сервые, и какие то пробелмы с белым фоном https://prnt.sc/9vRvF2ngAnq_

Ссылка на комментарий
Поделиться на других сайтах


03.03.2022 в 12:09, shweder сказал:

 

отчистил весь кеш,  ситауция сдвинулась с места

желтые полоски ушли, но теперь есть сервые, и какие то пробелмы с белым фоном https://prnt.sc/9vRvF2ngAnq_

значит что то сделали не так, или у вас кто то вносил свои правки в этот файл. в общем это все смотреть надо, обратитесь в раздел услуг или посмотрите родной файл версии 2.3, может просто попробовать заменить на родной файл, а свой пока в сторонку убрать и потестировать

Ссылка на комментарий
Поделиться на других сайтах

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.