简体   繁体   English

如何在magento上显示照片

[英]how to show photos on magento

i would like to show my members uploaded photo on my account of magento but can't get it. 我想显示我的会员在我的magento帐户上上传的照片,但无法获取。 My sql query is ok showing the results just fine. 我的SQL查询正常,显示结果很好。

I tried : echo '<img src="members/crazy.jpg" alt="Member Photo" /><br/>'; 我试过了: echo '<img src="members/crazy.jpg" alt="Member Photo" /><br/>'; the directory is ok but still the image is not show. 该目录是可以的,但仍未显示该图像。

Is there any different comment to show photos on magento how i will able to do that can anybody tell me with the directory ? 有什么不同的评论可以在magento上显示照片,我将如何做到这一点?有人可以告诉我该目录吗?

What happens when you try to open the image in a browser? 当您尝试在浏览器中打开图像时会发生什么? eg http://yoursite.com/members/crazy.jpg ? 例如http://yoursite.com/members/crazy.jpg

If you check your media folder in magento and copy the .htaccess file from there into the members directory it should fix it. 如果您在magento中检查媒体文件夹,然后将.htaccess文件从那里复制到成员目录,则应该对其进行修复。

If you don't have the .htaccess file in the folder it uses the .htacces from the main directory which would not allow direct access to these files. 如果文件夹中没有.htaccess文件,它将使用主目录中的.htacces,这将不允许直接访问这些文件。

The example path is relative, it does not start with a solidus ( / ). 示例路径是相对的,它不是以固线( / )开头。 This means a browser will interpret it differently depending on which page it is viewed from. 这意味着浏览器将根据从哪个页面查看来不同地解释它。 You can probably get around this by making it absolute but the preferred way is to use getUrl which uses the configured store domain and decides between http or https plus many other considerations. 您可以通过将其设置为绝对值来解决此问题,但是首选方法是使用getUrl ,该方法使用已配置的存储域并在httphttps以及其他许多注意事项之间进行决定。

echo sprintf('<img src="%s" alt="Member Photo" />',
    Mage::getUrl('members/crazy.jpg', array('type' => 'direct_link');

Here's the same thing done from a template file: 这是通过模板文件完成的相同操作:

<img src="<?php
    echo $this->getUrl('members/crazy.jpg', array('type' => 'direct_link')
?>" alt="Member Photo" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM