Search code examples
magentomagento-1.13

Magento EE 1.13.0.2: Customer Attribute Input type Image


I was quite happy to be able to add custom customer attributes through the admin in Enterprise. It saves a lot of time and effort opposed to how you have to add them in community.

What I find quite nifty is the input type "image", which makes it possible for a customer to upload an image. But when a customer uploads an image through this attribute the image is uploaded to "media/customer" and this directory by default has an .htacces that deny's any access.

The issue that I have at hand is that I have added an attribute called "avatar" that the customer can use to upload an image. Now I want to show this image on the dasboard of the "My account" section but the .htaccess file in the "media/customer" directory is preventing me from doing that.

Can I remove / adjust the .htaccess file? or is there a different method to show images that are stored in "media/customer"?.

I am showing the avatar using:

<?php $_file = 'customer' . $this->getCustomer()->getAvatar() ?>
<?php if(file_exists(Mage::getBaseDir('media') . '/' . $_file)): ?>
<?php $_imgUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $_file ?>
<?php else: ?> <?php $_imgUrl = $this->getSkinUrl('images/default_avatar.gif', array('_secure'=>true)) ?>
<?php endif; ?>
<div class="avatar"> <img src="<?php echo $_imgUrl ?>" height="91" width="91" /> </div>

Solution

  • in your .htaccess, add a 3rd line with:

    allow from YOUR_SERVER_IP