addField类型图像和缩略图路径

addField类型图像和缩略图路径

本文介绍了addField类型图像和缩略图路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Magento网店,刚刚创建了一个带扩展名的自定义模块(Modulecreator)。该模块带有标准管理界面,可以处理文件上传。我发现如果你想显示缩略图你可以使用'image'字段类型(addField('myfield','image'))而不是'file'类型字段。

I have a Magento webshop and just created a custom module with the extension (Modulecreator). This module comes with a standard admin interface that can handle file uploads. I found out that if you want to show thumbnails you can use the 'image' field type (addField('myfield', 'image')) instead of the 'file' type field.

但现在我遇到了问题。当我上传文件时,我将它们保存在'media'目录中名为'slides'的子目录中。但是当我编辑项目时,uploadfield旁边的缩略图的图像路径被设置为'media'文件夹。不是我的文件夹,因为我将其设置为'media / slides /'。

But now i've got a problem. When I upload files, I save them in a subdirectory called 'slides' in the 'media' directory. But when I edit the item, the image path for the thumbnail next to the uploadfield is set to the 'media' folder. Not my folder as I set it to 'media/slides/'.

我使用以下代码:

$fieldset->addField('filename', 'image', array(
        'label'     => Mage::helper('slideshow')->__('File'),
        'required'  => true,
        'name'      => 'filename',
        ));

我试图在数组中设置'path'键,但这不会被拾取通过Magento。讨厌Magento对缺乏良好且易于使用的文档的支持...

I tried to set a 'path' key in the array, but this doesn't get picked up by Magento. Hate the lack of support for good and easy to use documentation by Magento...

也许你可以帮我找到解决方案?

Maybe you can help me out to find a solution?

推荐答案

其他解决方案只是在magento调用$ form-> setValues(...)
之后编辑你的路径基本上在返回之前,做一些像这个:

other solution is just to edit your path after magento call $form->setValues(...)basically before return, do somehting like this:

  $p = $form->getElement('filename')->getValue();
  $form->getElement('filename')->setValue('media/slides' . $p);

.gondo

这篇关于addField类型图像和缩略图路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 20:08