Snippets

Shannon Briggs Remove spaces from image file names

Created by Shannon Briggs

File oc2.x.-2.2-optional-fix-filemanager1.0.2.final.ocmod Added

  • Ignore whitespace
  • Hide word diff
+<?xml version="1.0" encoding="utf-8"?>
+<modification>
+  <name>Opencart 2.x-2.2 filemanager upload_add_underscore and view-fix</name>
+  <code>8859B85845BE3476E907250B88</code>
+  <version>1.0.2</version>
+  <author>ojars26</author>
+  <file path="admin/controller/common/filemanager.php">
+	<operation>
+      <search>
+        <![CDATA['name'  => implode(' ', $name),]]>
+      </search>
+      <add position="replace">
+        <![CDATA['name'  => basename($image), //without added spaces, longnames fixed with in filemanager.tpl adding style="word-wrap: break-word;"]]>
+      </add>
+    </operation>
+	<operation>
+      <search>
+        <![CDATA[$filename = basename(html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8'));]]>
+      </search>
+      <add position="after">
+        <![CDATA[$filename = str_replace(' ', '_', preg_replace('/\s+/', ' ', $filename)); //Remove extra spaces & replace spaces with underscore]]>
+      </add>
+    </operation>
+  </file>
+  <file path="admin/view/template/common/filemanager.tpl">
+	<operation>
+      <search>
+        <![CDATA[<div class="col-sm-3 text-center">]]>
+      </search>
+      <add position="replace">
+        <![CDATA[<div class="col-sm-3 text-center" style="word-wrap: break-word;">]]>
+      </add>
+    </operation>
+  </file>
+</modification>