Magento 2.1 电子邮件徽标图像功能不起作用,上传后图像损坏
Magento 2.1 email logo image function not working, broken image after upload
步骤:
1. 前往 Magento 管理员。
2. 在路径 Content -> Configuration -> Transactional Email -> Logo Image 中上传 Email logo
3.保存
预期结果 -
新电子邮件徽标应显示在新订单(所有)电子邮件中
实际结果 -
徽标图像 URL 在路径内容 -> 配置 -> 交易电子邮件 -> 徽标图像下的预览中损坏。
这个问题是由于文件夹权限引起的基本上你需要给你的文件夹777适当的权限。你也可以通过inspect element检查,目录中没有图像。希望这个答案适合你。
找到了这个问题的解决方案:
我创建了一个覆盖 Magento\Theme\Model\Design\Backend\Logo 的自定义模块 (Ct_EmailLogo)
所以基本上,我们需要两个主要文件:
- \app\code\Ct\EmailLogo\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Theme\Model\Design\Backend\Logo" type="Ids\EmailLogo\Model\Design\Backend\Logo"/>
</config>
- \app\code\Ids\EmailLogo\Model\Design\Backend\Logo.php
命名空间Ids\EmailLogo\Model\Design\Backend;
class 徽标扩展 \Magento\Theme\Model\Design\Backend\Logo {
/**
* The tail part of directory path for uploading
*
*/
const UPLOAD_DIR = 'email/logo';
/**
* Return path to directory for upload file
*
* @return string
* @throw \Magento\Framework\Exception\LocalizedException
*/
protected function _getUploadDir() {
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}
/**
* Makes a decision about whether to add info about the scope.
*
* @return boolean
*/
protected function _addWhetherScopeInfo() {
return true;
}
/**
* Getter for allowed extensions of uploaded files.
*
* @return string[]
*/
public function getAllowedExtensions() {
return ['jpg', 'jpeg', 'gif', 'png', 'svg'];
}
}
本模块所需的其他文件将是基本文件
\app\code\Ids\EmailLogo\registration.php 和 \app\code\Ids\EmailLogo\etc\module.xml
就是这样..
快乐编码! :)
对于 magento 2 电子邮件交易徽标。我们还更改了供应商文件夹中的电子邮件模块。
In
vendor/magento/module-email/view/adminhtml/ui_component/design_config_form.xml
网上16号左右把代码换成这个
<field name="email_logo" formElement="fileUploader">
replace with
<field name="email_logo" formElement="imageUploader">
这是已知问题。
最佳解决方案是使用主题上传徽标:
替换名为 logo_email.png 的徽标位于:
app/design/frontend/[themeVendor]/[theme]/Magento_Email/web/logo_email.png
打开文件 header.html 位于:
app/design/frontend/[themeVendor]/[theme]/Magento_Email/email/header.html
编辑徽标的 宽度 和 高度 属性
{{if logo_width}}
width="{{var logo_width}}"
{{else}}
width="200"
{{/if}}
{{if logo_height}}
height="{{var logo_height}}"
{{else}}
height="100"
{{/if}}
步骤: 1. 前往 Magento 管理员。 2. 在路径 Content -> Configuration -> Transactional Email -> Logo Image 中上传 Email logo 3.保存
预期结果 - 新电子邮件徽标应显示在新订单(所有)电子邮件中
实际结果 - 徽标图像 URL 在路径内容 -> 配置 -> 交易电子邮件 -> 徽标图像下的预览中损坏。
这个问题是由于文件夹权限引起的基本上你需要给你的文件夹777适当的权限。你也可以通过inspect element检查,目录中没有图像。希望这个答案适合你。
找到了这个问题的解决方案:
我创建了一个覆盖 Magento\Theme\Model\Design\Backend\Logo 的自定义模块 (Ct_EmailLogo) 所以基本上,我们需要两个主要文件:
- \app\code\Ct\EmailLogo\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Theme\Model\Design\Backend\Logo" type="Ids\EmailLogo\Model\Design\Backend\Logo"/>
</config>
- \app\code\Ids\EmailLogo\Model\Design\Backend\Logo.php
命名空间Ids\EmailLogo\Model\Design\Backend;
class 徽标扩展 \Magento\Theme\Model\Design\Backend\Logo {
/**
* The tail part of directory path for uploading
*
*/
const UPLOAD_DIR = 'email/logo';
/**
* Return path to directory for upload file
*
* @return string
* @throw \Magento\Framework\Exception\LocalizedException
*/
protected function _getUploadDir() {
return $this->_mediaDirectory->getRelativePath($this->_appendScopeInfo(self::UPLOAD_DIR));
}
/**
* Makes a decision about whether to add info about the scope.
*
* @return boolean
*/
protected function _addWhetherScopeInfo() {
return true;
}
/**
* Getter for allowed extensions of uploaded files.
*
* @return string[]
*/
public function getAllowedExtensions() {
return ['jpg', 'jpeg', 'gif', 'png', 'svg'];
}
}
本模块所需的其他文件将是基本文件
\app\code\Ids\EmailLogo\registration.php 和 \app\code\Ids\EmailLogo\etc\module.xml
就是这样.. 快乐编码! :)
对于 magento 2 电子邮件交易徽标。我们还更改了供应商文件夹中的电子邮件模块。
In vendor/magento/module-email/view/adminhtml/ui_component/design_config_form.xml
网上16号左右把代码换成这个
<field name="email_logo" formElement="fileUploader">
replace with
<field name="email_logo" formElement="imageUploader">
这是已知问题。
最佳解决方案是使用主题上传徽标:
替换名为 logo_email.png 的徽标位于:
app/design/frontend/[themeVendor]/[theme]/Magento_Email/web/logo_email.png
打开文件 header.html 位于:
app/design/frontend/[themeVendor]/[theme]/Magento_Email/email/header.html
编辑徽标的 宽度 和 高度 属性
{{if logo_width}} width="{{var logo_width}}" {{else}} width="200" {{/if}} {{if logo_height}} height="{{var logo_height}}" {{else}} height="100" {{/if}}