File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Controller/Adminhtml/Post Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -71,12 +71,20 @@ protected function _beforeSave($model, $request)
7171
7272 $ model ->setData ($ key , $ image );
7373 } else {
74- if (isset ($ data [$ key ][0 ]['url ' ])
75- && false != ($ position = strpos ($ data [$ key ][0 ]['url ' ], '/media/ ' ))) {
76- $ model ->setData (
77- $ key ,
78- substr ($ data [$ key ][0 ]['url ' ], $ position + strlen ('/media/ ' ))
79- );
74+ if (isset ($ data [$ key ][0 ]['url ' ]) && false !== strpos ($ data [$ key ][0 ]['url ' ], '/media/ ' )) {
75+ $ url = $ data [$ key ][0 ]['url ' ];
76+
77+ /**
78+ * $url may have two types of values
79+ * /media/.renditions/magefan_blog/a.png
80+ * http://crowdin.dev.magefan.top/media/magefan_blog/tmp/a.png
81+ */
82+
83+ $ keyString = strpos ($ url , '/.renditions/ ' ) !== false ? '/.renditions/ ' : '/media/ ' ;
84+ $ position = strpos ($ url , $ keyString );
85+
86+ $ model ->setData ($ key , substr ($ url , $ position + strlen ($ keyString )));
87+
8088 } elseif (isset ($ data [$ key ][0 ]['name ' ])) {
8189 $ model ->setData ($ key , $ data [$ key ][0 ]['name ' ]);
8290 }
You can’t perform that action at this time.
0 commit comments