Jump to content

Images does not display for some reasons


Recommended Posts

Hey guys,

 

I'm pretty new to PrestaShop and have to continue one guy's development.

 

There is a horrible thing that happend after some of his actions: Images does not display in the shop for some reasons... I checked a couple of solutions but it didn't work for me.

 

The image url is something like:

http://www.sdveles.ru/c/34-category/RUSSIAN.jpg'>http://www.sdveles.ru/c/34-category/RUSSIAN.jpg

And if I connect to the server via FileZilla, I can find a correct image at this location : /c/34-category/RUSSIAN.jpg ..

 

I've seen that problem can appear after enabling Friendly URLs. In those cases people usually can't locate an image in the ftp-folder same as URL. So I think this is not my case... And I'm afraid of re-enabling Friendly URLs, because i think it may cause some harmfull actions to the store (please correct me if Im wrong)...

 

So. Could you please advise me something of your huge experience, because I'm really out of ideas...

 

PrestaShop 1.5.4

http://www.sdveles.ru

Example with images not displaying: http://www.sdveles.ru/34-RUSSIAN

 

Thanks in advance,

Anton

Link to comment
Share on other sites

everything is okay. path that you mentioned: http://www.sdveles.r...ory/RUSSIAN.jpg

isnt "real" path to the file. It's virtual path created with prestashop feature "friendly url".

 

category images you can find in the /img/ directory located in root dir of your prestashop store. And url above is a "virtual" redirection to the /img/ directory

Uhm.. Yes, I lied and you are right :) so the path to an image is like /c/34-category/RUSSIAN.jpg

By the same time, at the FTP-server, the correct image is in the folder /http/img/c/34-category.jpg.

Does it mean, that I should be able to access an image through the following url: sitename/img/c/34-category.jpg?

 

UPDATED: Well, I tried to access an image through sitename/img/c/34-category.jpg and it was quite fine. May be there is something wrong with those friendly urls?

Edited by ifoxxy (see edit history)
Link to comment
Share on other sites

mod rewrite (friendly urls) feature exist on your hosting account (your website works well)

the problem is with .htaccess file, try to regenerate it

I've Googled a bit about regenerating .htaccess file and found the following article: http://mypresta.eu/en/art/basic-tutorials/how-to-regenerate-htaccess-in-prestashop-1-5.html

I used the last method: Regenerate in back office: Turning multistore on, and then turning multistore off

Should it be enough?

If so, It didn't affect anything...

Link to comment
Share on other sites

it's wierd that you've got RUSSIAN in the url, maybe it's issue related to the template? have you changed something related to the getimagelink() function?

Thanks for a new idea.. As I understood "RUSSIAN" is a friendly url selected for the specific category..

 

Where can I find this getimageling() function to get sure that it is correct?

Link to comment
Share on other sites

it's wierd that you've got RUSSIAN in the url, maybe it's issue related to the template? have you changed something related to the getimagelink() function?

I've found a getimagelink() function in Link.php:

public function getImageLink($name, $ids, $type = null)
{
 $not_default = false;
 // legacy mode or default image
 $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
 if ((Configuration::get('PS_LEGACY_IMAGES')
  && (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg')))
  || ($not_default = strpos($ids, 'default') !== false))
 {
  if ($this->allow == 1 && !$not_default)
   $uri_path = __PS_BASE_URI__.$ids.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
  else
   $uri_path = _THEME_PROD_DIR_.$ids.($type ? '-'.$type : '').$theme.'.jpg';
 }
 else
 {
  // if ids if of the form id_product-id_image, we want to extract the id_image part
  $split_ids = explode('-', $ids);
  $id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
  $theme = ((Shop::isFeatureActive() && file_exists(_PS_PROD_IMG_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'-'.(int)Context::getContext()->shop->id_theme.'.jpg')) ? '-'.Context::getContext()->shop->id_theme : '');
  if ($this->allow == 1)
   $uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').$theme.'/'.$name.'.jpg';
  else
   $uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').$theme.'.jpg';
 }
 return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}

Is it the same as default one? I couldn't find any examples...

Link to comment
Share on other sites

it looks well, can you show how the function looks like in the .tpl files?

I found this in Category.tpl:

<img src="{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category')}" alt="{$category->name|escape:'htmlall':'UTF-8'}" title="{$category->name|escape:'htmlall':'UTF-8'}" id="categoryImage" width="{$categorySize.width}" height="{$categorySize.height}" />

And here is the function getCatImageLink() from Link.php

 

public function getCatImageLink($name, $id_category, $type = null)
{
$uri_path = ($this->allow == 1) ? (__PS_BASE_URI__.'c/'.$id_category.($type ? '-'.$type : '').'/'.$name.'.jpg') : (_THEME_CAT_DIR_.$id_category.($type ? '-'.$type : '').'.jpg');
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}

It doesn't seem wrong... What should I be looking for?

Link to comment
Share on other sites

×
×
  • Create New...