A
A
Alexander2015-09-12 00:03:40
PHP
Alexander, 2015-09-12 00:03:40

Images are not displayed after site migration, what could be the reason?

On the old hosting, everything is arranged like this.
there are two sites. two folders .. one site.ru and the second m.site.ru.
On the mobile version of the site, when images are displayed, it happens with the help of htaccess - resize images, which are located in the site.ru folder.

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/products/(.+) resize/resize.php?file=$1&token=%{QUERY_STRING}

resize.php file
$filename = $_GET['file'];
$token = $_GET['token'];
$resized_filename =  $simpla->image->resize($filename);

if(is_readable($resized_filename)) /* Возвращает true */ 
{
  header('Content-type: image');
  print file_get_contents($resized_filename);

}

The resize function itself
function resize($filename)
  {
    list($source_file, $width , $height, $set_watermark) = $this->get_resize_params($filename);


    // Если вайл удаленный (http://), зальем его себе
    if(substr($source_file, 0, 7) == 'http://')
    {	
      // Имя оригинального файла
      if(!$original_file = $this->download_image($source_file))
        return false;
      
      $resized_file = $this->add_resize_params($original_file, $width, $height, $set_watermark);			
    }	
    else
    {
      $original_file = $source_file;
    }
    
    $resized_file = $this->add_resize_params($original_file, $width, $height, $set_watermark);			
    
  
    // Пути к папкам с картинками
    $main_site_root_dir = "/var/www/vhosts/site.ru/httpdocs/";
    /*$originals_dir = $this->config->root_dir.$this->config->original_images_dir;
    $preview_dir = $this->config->root_dir.$this->config->resized_images_dir;*/
    $originals_dir = $main_site_root_dir.$this->config->original_images_dir;

    $preview_dir = $main_site_root_dir.$this->config->resized_images_dir;
    
    $watermark_offet_x = $this->settings->watermark_offset_x;
    $watermark_offet_y = $this->settings->watermark_offset_y;
    
    $sharpen = min(100, $this->settings->images_sharpen)/100;
    $watermark_transparency =  1-min(100, $this->settings->watermark_transparency)/100;
  
  
    if($set_watermark && is_file($this->config->root_dir.$this->config->watermark_file))
      $watermark = $this->config->root_dir.$this->config->watermark_file;
    else
      $watermark = null;

    if(class_exists('Imagick') && $this->config->use_imagick)
      $this->image_constrain_imagick($originals_dir.$original_file, $preview_dir.$resized_file, $width, $height, $watermark, $watermark_offet_x, $watermark_offet_y, $watermark_transparency, $sharpen);
    else
      $this->image_constrain_gd($originals_dir.$original_file, $preview_dir.$resized_file, $width, $height, $watermark, $watermark_offet_x, $watermark_offet_y, $watermark_transparency);
    return $preview_dir.$resized_file;
  }

On the new hosting, it doesn't want to show pictures.. I saw some strange errors in the logs, I couldn't make them out..
File does not exist: /var/www/vhosts/site.ru/m.site.ru/\xef\xbb\xbfhttp:, referer: http://m.site.ru/product/sds

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Sinitsyn, 2015-09-12
@Dil0ng

There, non-displayed images have some non-displayed characters at the beginning of the url that confuse everyone.
EF BB BF 68 74 74

Денис, 2015-09-12
@prototype_denis

EF BB BF - это сигнатура BOM

Александр, 2015-09-13
@Dil0ng Автор вопроса

Всем спасибо. Действительно все дело было из этих символов, BOM, пересохранил файл в кодировке UTF без bom и все заработало

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question