1

The default file name separator for Expression Engine is an underscore. And this cannot be changed. But the url title word separator is.

For seo purposes, our client asked if it is possible to use dashes instead of underscores in (image) filenames. (source)

So I had a look into it. We're using assets and ce_image for this project. And I found a lot of php code replacing special characters and spaces with underscores. Seems like it is hardcoded in many of the add-ons. And that concerns me.

So I'm wondering if anyone has tried to do the same? For example. There's a clean_filename function in the Assets_lib.php. Is just rewriting that function enough to replace all underscores with dashes for new uploads. Or is it more complex than that?

2 Answers 2

1

I'm gonna say it's way more complex. It's possible that it's simply matter of replacing all filename handlers and actions with ones to suite your needs (replace with dashes instead of underscores), but it might involve some deep core modification.

Also, anytime you install a new addon that has any file functionality, you'll need to scan it in case it handles filenames internally instead of using EE methods (that Assets hooks into).

Annnd anytime you upgrade EE, you'll have to have any core modifications you've made documented so you can reimplement them after upgrade.

Unless someone out there can report going through this process, I'm going to guess you'll have to do it yourself. I would recommend launching a new development server and repo branch of your application to start the process. It may end up much simpler than expected (like I said, hopefully someone can chime in and has done this already), but the biggest part will be very careful testing and QA of these changes before pushing to staging or production.

Start by looking at the File_field, File_integrity, and Filemanager library files in EE, as well as the Upload library file in CI. Good luck.

3
  • We discussed it, and changing EE libraries wasn't a feasible solution. But we've found an easier solution using ce_image. The tag support a "filename" parameter. Using the url_title in combination with a counter (or other unique string) solved our issue.
    – Diederik
    Feb 11, 2016 at 13:37
  • Ooof, I totally missed the mark on your issue. I suggest you answer your own question with your solution and accept after the waiting period; I'll up-vote you. Your self-accepted answer can definitely help others with this issue, so let's share.
    – jrothafer
    Feb 14, 2016 at 4:03
  • I will do that. :-)
    – Diederik
    Feb 15, 2016 at 9:30
1

The easiest workaround seems to be using CE_Image. It offers a filename parameter.

We chose to use the url_title of the article, in combination with a counter (or other unique string). That solved our issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.