Jump to content

Category images not working


Recommended Posts

I'm unable to get the category thumbnail images to show up.

 

Permissions have been set recursively to 777 on img/

 

htaccess has been regenerated several times. Thumbnails have been regenerated. The category thumbnail is visible in the category edit backoffice

 

When I print this:

{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category_default')|escape:'html':'UTF-8'}

 

it shows:

http://localhost/c/-category_default/t-shirts.jpg

 

Notice the dash before the image type ( -category_default ). If I visit that URI directly there's no image. If I remove the "-" and visit the URI it is still not there.

 

No errors are generated in the php-error.log or running pretstashop in dev mode.

 

I think this is a problem with the htaccess rewrite.

 

Any help would be greatly appreciated. Thanks!

Link to comment
Share on other sites

I don't think it will hit the rewrite rules when you call getCatImageLink directly, might be your friendly url settings in Preferences > SEO & Urls.

 

Route to category should be '{id}-{rewrite}', and are you sure $category has been initialized correctly?

Link to comment
Share on other sites

Thanks for your reply. The route to the category is as you suggested '{id}-{rewrite}'.

 

Category object looks like this:

 

[id] => 3
[id_category] => 3
[name] => T-Shirts
[active] => 1
[position] => 1
[description] =>description

[id_parent] => 2
[id_category_default] =>
[level_depth] => 2
[nleft] => 3
[nright] => 28
[link_rewrite] => t-shirts
[meta_title] => title
[meta_keywords] =>
[meta_description] => desc
[date_add] => 2013-09-15 16:29:53
[date_upd] => 2016-07-08 16:44:46
[is_root_category] => 0
[id_shop_default] => 1
[groupBox] =>
[id_image] =>
[webserviceParameters:protected] => Array
(
[objectsNodeName] => categories
[hidden_fields] => Array
(
[0] => nleft
[1] => nright
[2] => groupBox
)

[fields] => Array
(
[id_parent] => Array
(
[xlink_resource] => categories
)

[level_depth] => Array
(
[setter] =>
)

[nb_products_recursive] => Array
(
[getter] => getWsNbProductsRecursive
[setter] =>
))

[associations] => Array
(
[categories] => Array
(
[getter] => getChildrenWs
[resource] => category
)

[products] => Array
(
[getter] => getProductsWs
[resource] => product
)))

[id_lang:protected] => 1
[id_shop:protected] => 1
[id_shop_list] =>
[get_shop_from_context:protected] => 1
[table:protected] => category
[identifier:protected] => id_category
[fieldsRequired:protected] => Array
(
[0] => active
)

[fieldsSize:protected] => Array
(
)

[fieldsValidate:protected] => Array
(
[nleft] => isUnsignedInt
[nright] => isUnsignedInt
[level_depth] => isUnsignedInt
[active] => isBool
[id_parent] => isUnsignedInt
[id_shop_default] => isUnsignedId
[is_root_category] => isBool
[date_add] => isDate
[date_upd] => isDate
)

[fieldsRequiredLang:protected] => Array
(
[0] => name
[1] => link_rewrite
)

[fieldsSizeLang:protected] => Array
(
[name] => 128
[link_rewrite] => 128
[meta_title] => 128
[meta_description] => 255
[meta_keywords] => 255
)

[fieldsValidateLang:protected] => Array
(
[name] => isCatalogName
[link_rewrite] => isLinkRewrite
[description] => isCleanHtml
[meta_title] => isGenericName
[meta_description] => isGenericName
[meta_keywords] => isGenericName
)

[tables:protected] => Array
(
)

[image_dir:protected] => /Users/username/Sites/localhost/img/c/
[image_format:protected] => jpg
[def:protected] => Array
(
[table] => category
[primary] => id_category
[multilang] => 1
[multilang_shop] => 1
[fields] => Array
(
[nleft] => Array
(
[type] => 1
[validate] => isUnsignedInt
)

[nright] => Array
(
[type] => 1
[validate] => isUnsignedInt
)

[level_depth] => Array
(
[type] => 1
[validate] => isUnsignedInt
)

[active] => Array
(
[type] => 2
[validate] => isBool
[required] => 1
)

[id_parent] => Array
(
[type] => 1
[validate] => isUnsignedInt
)

[id_shop_default] => Array
(
[type] => 1
[validate] => isUnsignedId
)

[is_root_category] => Array
(
[type] => 2
[validate] => isBool
)

[position] => Array
(
[type] => 1
)

[date_add] => Array
(
[type] => 5
[validate] => isDate
)

[date_upd] => Array
(
[type] => 5
[validate] => isDate
)

[name] => Array
(
[type] => 3
[lang] => 1
[validate] => isCatalogName
[required] => 1
=> 128
)

[link_rewrite] => Array
(
[type] => 3
[lang] => 1
[validate] => isLinkRewrite
[required] => 1
=> 128
)

[description] => Array
(
[type] => 6
[lang] => 1
[validate] => isCleanHtml
)

[meta_title] => Array
(
[type] => 3
[lang] => 1
[validate] => isGenericName
=> 128
)

[meta_description] => Array
(
[type] => 3
[lang] => 1
[validate] => isGenericName
=> 255
)

[meta_keywords] => Array
(
[type] => 3
[lang] => 1
[validate] => isGenericName
=> 255
))

[classname] => Category
[associations] => Array
(
[l] => Array
(
[type] => 2
[field] => id_category
[foreign_field] => id_category
)))

Link to comment
Share on other sites

id_image doesn't have a value, does it work with $category->id?  Can't remember offhand what you're supposed to pass here.

[id_shop_default] => 1
[groupBox] =>
[id_image] =>
[webserviceParameters:protected] => Array
{$link->getCatImageLink($category->link_rewrite, $category->id_image, 'category_default')|escape:'html':'UTF-8'}
Link to comment
Share on other sites

this seems to be the only reason your id_image wouldn't be set, is there a 3.jpg in <root>/img/c/ directory?

$this->id_image = ($this->id && file_exists(_PS_CAT_IMG_DIR_.(int)$this->id.'.jpg')) ? (int)$this->id : false;
Link to comment
Share on other sites

 

I'm unable to get the category thumbnail images to show up.

 

Permissions have been set recursively to 777 on img/

 

htaccess has been regenerated several times. Thumbnails have been regenerated. The category thumbnail is visible in the category edit backoffice

 

let's clarify, you uploaded image of category, or thumbnail of category?

these two things are different, and image of caregory will appear as a image of category (cover)

thumbnail is not a cover of category

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...