1
bjuti
How imagemanager not to randomize image filename?
  • 2012/11/25 10:05

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Randomized image filename is not good seo strategy. I've read this topic and try to apply hack, but it's not working.

So, my question is how to have normal image filename when I upload picture in imagemanager, not the randomized one?

Tnx.

2
bjuti
Re: How imagemanager not to randomize image filename?
  • 2012/11/25 10:27

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


I've found it!

In file 'modules/system/admin/images/main.php'

remove or put under comment line 438:
$uploader->setPrefix('img');

3
bjuti
Re: How imagemanager not to randomize image filename?
  • 2012/11/27 18:26

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


Well it's not working.

It is working when I use system module image manager and upload picture from it. But when I click in eg. TinyMCE to add a picture it's stil img8746we8q.jpg or something.

Any idea, please?

4
trabis
Re: How imagemanager not to randomize image filename?
  • 2012/11/28 0:28

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


You need to make changes in file class/uploader.php

Line 354:
if (isset($this->targetFileName)) {
            
$this->savedFileName $this->targetFileName;
        } else if (isset(
$this->prefix)) {
            
$this->savedFileName uniqid($this->prefix) . '.' strtolower($matched[1]);
        } else {
            
$this->savedFileName strtolower($this->mediaName);
        }


If you want to use file name:
if (isset($this->targetFileName)) {
            
$this->savedFileName $this->targetFileName;
        } else {
            
$this->savedFileName strtolower($this->mediaName);
        }

Will save as: 'the_file_name.jpg'

If you want to use both file name and prefix (you should use this to prevent overwrite an already existing image with the same file name):
if (isset($this->targetFileName)) {
            
$this->savedFileName $this->targetFileName;
        } else if (isset(
$this->prefix)) {
            
$this->savedFileName strtolower(str_replace($matched[0], ''$this->mediaName) . '-' uniqid($this->prefix) .  $matched[0]);
        } else {
            
$this->savedFileName strtolower($this->mediaName);
        }

Will save as: 'the_file_name-img50b558777727d.jpg'

5
bjuti
Re: How imagemanager not to randomize image filename?
  • 2012/11/28 16:14

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


It works! Tnx!

6
bjuti
Re: How imagemanager not to randomize image filename?
  • 2012/11/28 19:57

  • bjuti

  • Just can't stay away

  • Posts: 871

  • Since: 2009/1/7 2


It's all working fine, but I've found restriction od imagename of 24 chars. Is it possible to override it?

Login

Who's Online

209 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 209


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits