Jump to content


Photo

Xinha image uploader changing filename - dashes to underscores


  • Please log in to reply
10 replies to this topic

#1 cathode

cathode

    Loves Etomite Forums!

  • Staff
  • 663 posts

Posted 07 October 2008 - 08:03 PM

I just noticed that uploading images from within the Xinha editor renames images with dashes - making them underscores. Has anyone else noticed this? It's hard to believe I haven't run into this before...

#2 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 07 October 2008 - 09:55 PM

I just noticed that uploading images from within the Xinha editor renames images with dashes - making them underscores. Has anyone else noticed this? It's hard to believe I haven't run into this before...


never noticed, but yeah it does for me too... that could potentially make managing images confusing. I use the file manager, the Xinha image manager, and other software (dreamweaver, filezilla) to upload files so i'll have to keep a close eye on local vs remote image names.

thanks for bringing this up.

#3 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 07 October 2008 - 10:31 PM

I've never noticed but, then again, I rarely upload through Xinha with hyphens either... I wonder if their site has info on this functionality...

#4 cathode

cathode

    Loves Etomite Forums!

  • Staff
  • 663 posts

Posted 08 October 2008 - 01:20 PM

never noticed, but yeah it does for me too... that could potentially make managing images confusing. I use the file manager, the Xinha image manager, and other software (dreamweaver, filezilla) to upload files so i'll have to keep a close eye on local vs remote image names.

thanks for bringing this up.


Thanks for confirming this, Darren!

#5 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 08 October 2008 - 03:45 PM

In here?
line 86, xinha/plugins/ImageManager/Classes/Files.php


[codebox]/**
* Escape the filenames, any non-word characters will be
* replaced by an underscore.
* @param string $filename the orginal filename
* @return string the escaped safe filename
*/
function escape($filename)
{
Return preg_replace('/[^\w\._]/', '_', $filename);
}[/codebox]

#6 cathode

cathode

    Loves Etomite Forums!

  • Staff
  • 663 posts

Posted 08 October 2008 - 03:57 PM

In here?
line 86, xinha/plugins/ImageManager/Classes/Files.php


/**	 * Escape the filenames, any non-word characters will be	 * replaced by an underscore.	 * @param string $filename the orginal filename	 * @return string the escaped safe filename	 */	function escape($filename) 	{		Return preg_replace('/[^\w\._]/', '_', $filename);	}


That looks like it may be it, I don't know enough to decode that preg_replace line, Ralph, can you see a way to make that not change dashes to underscores?

#7 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 08 October 2008 - 04:25 PM

yeah, i don't see hyphens in there..

#8 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts

Posted 08 October 2008 - 04:29 PM

Old
Return preg_replace('/[^\w\._]/', '_', $filename);


the carrot "^" means "except"...

New
Return preg_replace('/[^\w\._-]/', '_', $filename);

But I'm not sure of the full consequences with the xinha code for doing this...

#9 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 08 October 2008 - 05:42 PM

I really don't think there would be any implications in leaving hyphens in filenames... As far as I know all OS's and servers allow hyphens... Perhaps it was merely an oversight by the person who wrote that piece of code...

#10 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 08 October 2008 - 06:49 PM

the carrot "^" means "except"...


well i learned something new today, time to turn in. :D

thanks Cris.

#11 cathode

cathode

    Loves Etomite Forums!

  • Staff
  • 663 posts

Posted 08 October 2008 - 07:20 PM

Awesome- I learned something too- Thanks guys! I'll be trying this out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users