File tree 1 file changed +14
-6
lines changed
Controller/Adminhtml/Post
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)
71
71
72
72
$ model ->setData ($ key , $ image );
73
73
} 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
+
80
88
} elseif (isset ($ data [$ key ][0 ]['name ' ])) {
81
89
$ model ->setData ($ key , $ data [$ key ][0 ]['name ' ]);
82
90
}
You can’t perform that action at this time.
0 commit comments