Magento – Category Image / getImageUrl() is empty

categoryce-1.7.0.2imagetemplate

In back end I can see the category has an image but if I try to show it in a template it is empty:

  $_category = Mage::registry('current_category');
  $_imgUrl = $_category->getImageUrl();

Why is $_imgUrl empty?

Template file is \app\design\frontend\default\kemweb\template\page

var_dump($_category) looks like this:

`$_category` does contain the correct item (entity_id checked). Same code worked on other magento installation. Any clue what is going wrong here?

 object(Mage_Catalog_Model_Category)#96 (23) {
  ["_eventPrefix":protected]=>
  string(16) "catalog_category"
  ["_eventObject":protected]=>
  string(8) "category"
  ["_cacheTag":protected]=>
  string(16) "catalog_category"
  ["_useFlatResource":protected]=>
  bool(false)
  ["_designAttributes":"Mage_Catalog_Model_Category":private]=>
  array(6) {
    [0]=>
    string(13) "custom_design"
    [1]=>
    string(18) "custom_design_from"
    [2]=>
    string(16) "custom_design_to"
    [3]=>
    string(11) "page_layout"
    [4]=>
    string(20) "custom_layout_update"
    [5]=>
    string(24) "custom_apply_to_products"
  }
  ["_treeModel":protected]=>
  NULL
  ["_defaultValues":protected]=>
  array(1) {
    ["url_path"]=>
    string(13) "schenken.html"
  }
  ["_storeValuesFlags":protected]=>
  array(1) {
    ["url_path"]=>
    bool(true)
  }
  ["_lockedAttributes":protected]=>
  array(0) {
  }
  ["_isDeleteable":protected]=>
  bool(true)
  ["_isReadonly":protected]=>
  bool(false)
  ["_resourceName":protected]=>
  string(16) "catalog/category"
  ["_resource":protected]=>
  NULL
  ["_resourceCollectionName":protected]=>
  string(27) "catalog/category_collection"
  ["_dataSaveAllowed":protected]=>
  bool(true)
  ["_isObjectNew":protected]=>
  NULL
  ["_data":protected]=>
  array(34) {
    ["store_id"]=>
    string(1) "1"
    ["entity_id"]=>
    string(1) "3"
    ["entity_type_id"]=>
    string(1) "3"
    ["attribute_set_id"]=>
    string(1) "3"
    ["parent_id"]=>
    string(1) "2"
    ["created_at"]=>
    string(19) "2013-06-19 11:29:11"
    ["updated_at"]=>
    string(19) "2013-07-02 09:56:14"
    ["path"]=>
    string(5) "1/2/3"
    ["position"]=>
    string(1) "1"
    ["level"]=>
    string(1) "2"
    ["children_count"]=>
    string(1) "0"
    ["name"]=>
    string(8) "Schenken"
    ["url_key"]=>
    string(8) "schenken"
    ["meta_title"]=>
    NULL
    ["display_mode"]=>
    string(8) "PRODUCTS"
    ["custom_design"]=>
    NULL
    ["page_layout"]=>
    NULL
    ["url_path"]=>
    string(13) "schenken.html"
    ["thumbnail"]=>
    string(16) "cat_schenken.jpg"
    ["is_active"]=>
    string(1) "1"
    ["include_in_menu"]=>
    string(1) "1"
    ["landing_page"]=>
    NULL
    ["is_anchor"]=>
    string(1) "1"
    ["custom_use_parent_settings"]=>
    string(1) "0"
    ["custom_apply_to_products"]=>
    string(1) "0"
    ["description"]=>
    NULL
    ["meta_keywords"]=>
    NULL
    ["meta_description"]=>
    NULL
    ["custom_layout_update"]=>
    NULL
    ["available_sort_by"]=>
    NULL
    ["custom_design_from"]=>
    NULL
    ["custom_design_to"]=>
    NULL
    ["filter_price_range"]=>
    NULL
    ["path_ids"]=>
    array(3) {
      [0]=>
      string(1) "1"
      [1]=>
      string(1) "2"
      [2]=>
      string(1) "3"
    }
  }
  ["_hasDataChanges":protected]=>
  bool(true)
  ["_origData":protected]=>
  array(33) {
    ["store_id"]=>
    string(1) "1"
    ["entity_id"]=>
    string(1) "3"
    ["entity_type_id"]=>
    string(1) "3"
    ["attribute_set_id"]=>
    string(1) "3"
    ["parent_id"]=>
    string(1) "2"
    ["created_at"]=>
    string(19) "2013-06-19 11:29:11"
    ["updated_at"]=>
    string(19) "2013-07-02 09:56:14"
    ["path"]=>
    string(5) "1/2/3"
    ["position"]=>
    string(1) "1"
    ["level"]=>
    string(1) "2"
    ["children_count"]=>
    string(1) "0"
    ["name"]=>
    string(8) "Schenken"
    ["url_key"]=>
    string(8) "schenken"
    ["meta_title"]=>
    NULL
    ["display_mode"]=>
    string(8) "PRODUCTS"
    ["custom_design"]=>
    NULL
    ["page_layout"]=>
    NULL
    ["url_path"]=>
    string(13) "schenken.html"
    ["thumbnail"]=>
    string(16) "cat_schenken.jpg"
    ["is_active"]=>
    string(1) "1"
    ["include_in_menu"]=>
    string(1) "1"
    ["landing_page"]=>
    NULL
    ["is_anchor"]=>
    string(1) "1"
    ["custom_use_parent_settings"]=>
    string(1) "0"
    ["custom_apply_to_products"]=>
    string(1) "0"
    ["description"]=>
    NULL
    ["meta_keywords"]=>
    NULL
    ["meta_description"]=>
    NULL
    ["custom_layout_update"]=>
    NULL
    ["available_sort_by"]=>
    NULL
    ["custom_design_from"]=>
    NULL
    ["custom_design_to"]=>
    NULL
    ["filter_price_range"]=>
    NULL
  }
  ["_idFieldName":protected]=>
  string(9) "entity_id"
  ["_isDeleted":protected]=>
  bool(false)
  ["_oldFieldsMap":protected]=>
  array(0) {
  }
  ["_syncFieldsMap":protected]=>
  array(0) {
  }
}

Best Answer

I see that only the thumbnail attribute has a value (cat_schenken.jpg). In magento admin you can upload a category image and a category thumbnail image. So you probably uploaded only the thumbnail image and not the main image.

Try to use Zend_Debug::dump($_category->getData()) to have a better view of the category's attributes.