Page 1 of 2

system auto add space in image name

Posted: Sun Jun 19, 2016 10:55 pm
by vincent_angbt
space.png

space.png (48.62 KiB) Viewed 5842 times

as we can see, the image manager will show there is space add to the number character 15.
if the image name more than 15, then it will auto add white space and cause the og issue.

how can we solve this beside make the image name shorter than 15 character.

Re: system auto add space in image name

Posted: Mon Jun 20, 2016 3:39 am
by ojars26
I use this and it works for me! No-spaces in filename or directory

Re: system auto add space in image name

Posted: Mon Jun 20, 2016 8:28 am
by vincent_angbt
ojars26 wrote:I use this and it works for me! No-spaces in filename or directory
Hi, can give the link as my version is 2.0.1.2.

Thanks

Re: system auto add space in image name

Posted: Mon Jun 20, 2016 12:49 pm
by ojars26
It should work on all versions. 2.0.0.0 - 2.2.0.0

Re: system auto add space in image name

Posted: Tue Jun 21, 2016 5:04 pm
by vincent_angbt
Hi, its work...

2.1.0.2 auto remove space in image file name, in image ma...

Posted: Tue Jun 21, 2016 5:06 pm
by vincent_angbt
Hi,

I notice if the image with the space in the image files name, it will cause the og error.

How can I do in order the image manager will auto remove all the space in the image files name ?

Re: 2.1.0.2 auto remove space in image file name, in image m

Posted: Tue Jun 21, 2016 5:19 pm
by i2Paq
I have merged you 2 topics as they are about the same issue.

Re: 2.1.0.2 auto remove space in image file name, in image m

Posted: Tue Jun 21, 2016 5:21 pm
by Burt65
vincent_angbt wrote:Hi,

I notice if the image with the space in the image files name, it will cause the og error.

How can I do in order the image manager will auto remove all the space in the image files name ?
Hi Vincent

You are correct server don't like filename with spaces. You can use an extension that will also automatically replace empty spaces with an underscore so to eliminate this problem...

This is one for example:

http://www.opencart.com/index.php?route ... n_id=19083

Re: system auto add space in image name

Posted: Tue Jun 21, 2016 9:13 pm
by ojars26
Hi!
I updated the filemanager ocmod. now it will also add underscore when you upload image.

example:
upload = "image name u nderscore.jpg"
result = "image_name_____u_nderscore.jpg"

Re: system auto add space in image name

Posted: Tue Jun 21, 2016 9:23 pm
by straightlight
ojars26 wrote:Hi!
I updated the filemanager ocmod. now it will also add underscore when you upload image.

example:
upload = "image name u nderscore.jpg"
result = "image_name_____u_nderscore.jpg"
The mount of underscore should be filtered so to output a unique underscore when tracking filenames in case multiple instances of underscore would be used to the same location on a filename.

Re: system auto add space in image name

Posted: Tue Jun 21, 2016 9:39 pm
by ojars26
It is correctly filtered.

Code: Select all

upload =  "image name     u nderscore.jpg" 
result =  "image_name_____u_nderscore.jpg"

Re: system auto add space in image name

Posted: Tue Jun 21, 2016 10:03 pm
by straightlight
result = "image_name_____u_nderscore.jpg"
No, it's not. The mount of space shouldn't follow with the same mount of underscores. It should rather be filtered with a unique underscore on filenames.

Re: system auto add space in image name

Posted: Wed Jun 22, 2016 6:41 am
by ojars26
straightlight wrote:
result = "image_name_____u_nderscore.jpg"
No, it's not. The mount of space shouldn't follow with the same mount of underscores. It should rather be filtered with a unique underscore on filenames.
like this?

Code: Select all

upload =  "image name     u nderscore.jpg" 
result =  "image_name_u_nderscore.jpg"

Re: system auto add space in image name

Posted: Wed Jun 22, 2016 7:57 am
by straightlight
ojars26 wrote:
straightlight wrote:
result = "image_name_____u_nderscore.jpg"
No, it's not. The mount of space shouldn't follow with the same mount of underscores. It should rather be filtered with a unique underscore on filenames.
like this?

Code: Select all

upload =  "image name     u nderscore.jpg" 
result =  "image_name_u_nderscore.jpg"
Yes, that would be the right file structure. Although, I would also limit the string size in case it gets too long - ending with a random number as an ending length in case it would exceed the length of characters on the filename.

Re: system auto add space in image name

Posted: Wed Jun 22, 2016 1:04 pm
by vincent_angbt
ojars26 wrote:Hi!
I updated the filemanager ocmod. now it will also add underscore when you upload image.

example:
upload = "image name u nderscore.jpg"
result = "image_name_____u_nderscore.jpg"
Hi,
i am using default themes, will this override any files ?
and, i am using v2.1.0.2, this will work right, according to the http://www.opencart.com/index.php?route ... n_id=19083 it's compatible.

what's the different of:
PowerImageManager.MijoShop.ocmod.zip & PowerImageManager.3.1.4.ocmod.zip ???

Re: system auto add space in image name

Posted: Wed Jun 22, 2016 11:46 pm
by straightlight
Since you're using a contributed file manager, you'd need to contact the developer of that extension to get more information regarding your last enquiry.

Re: system auto add space in image name

Posted: Thu Jun 23, 2016 1:28 am
by vincent_angbt
straightlight wrote:Since you're using a contributed file manager, you'd need to contact the developer of that extension to get more information regarding your last enquiry.
if there any code we can change in order to achieve this ???

Re: system auto add space in image name

Posted: Thu Jun 23, 2016 1:37 am
by straightlight
what's the different of:
PowerImageManager.MijoShop.ocmod.zip & PowerImageManager.3.1.4.ocmod.zip
For those inquiries, you need to contact the developer of those contributions.

Re: system auto add space in image name

Posted: Thu Jun 23, 2016 4:18 am
by ojars26
this is my final change - made for my self. :)

Code: Select all

<?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>

Re: system auto add space in image name

Posted: Thu Jun 23, 2016 5:02 am
by straightlight
Thanks. So far, it would make sense to add this as a core fix in future releases. This is especially useful for POSIX-compliant file systems .