Welcome, Guest. Please login or register.
Did you miss your activation email?

 
Advanced search

22728 Posts in 6695 Topics- by 17594 Members - Latest Member: permsk

23-05-2019 16:07:34
JOOM::GALLERY::FORUMJoomGallery 3.x JUXMiscellaneousImprovement: change underscore with hyphens in file names
Pages: [1]
Print
Author Topic: Improvement: change underscore with hyphens in file names  (Read 2188 times)
0 Members and 1 Guest are viewing this topic.
siristru
Newbie
*
Offline Offline

Posts: 6


View Profile
« on: 30-06-2015 21:21:39 »

As JoomGallery is great extension but it has a serious drawback. Files created from uploaded images have names like:

konserwacja_-_pracownia_konserwacji_malarstwa_i_rzeby_polichromowanej_20150603_2084737421.jpg

And when we use real image URLs it impact severely on SEO.

It will be enough to change underscores with hyphens in those files:

/administrator/components/com_joomgallery/helpers/file.php line 100

Code
    // Replace whitespace with underscore
   array_push($filenamesearch, '\s');
   array_push($filenamereplace, '-');
   // Replace slash with underscore
   array_push($filenamesearch, '/');
   array_push($filenamereplace, '-');
   // Replace backslash with underscore
   array_push($filenamesearch, '\\\\');
   array_push($filenamereplace, '-');
   // Replace other stuff
   array_push($filenamesearch, '[^a-z_0-9-]');
   array_push($filenamereplace, '');

Also you'll need to change any appearance of '_' in that file to get SEO folder names.

/administrator/components/com_joomgallery/helpers/upload.php line 1706

Code
      // New filename
     if(is_null($filecounter))
     {
       $newfilename = $filename.'-'.$filedate.'-'.$randomnumber.'.'.$tag;
     }
     else
     {
       $newfilename = $filename.'-'.$filecounter.'-'.$filedate.'-'.$randomnumber.'.'.$tag;
     }

Not sure if this is needed but I changed it also:

/administrator/components/com_joomgallery/models/image.php line 624

Code
      // New filename
     $newfilename = $filename.'-'.$date.'-'.$randomnumber;

REF:

http://blog.woorank.com/2013/04/underscores-in-urls-why-are-they-not-recommended/

I did it myself but it's a core hack. And I'm not sure if I changed in every place that is needed, but those changes work as gold.

If you already have gallery on your site then you need to rename gallery folders and files (just copy them to your had and use batch name converter).
Then you need to convert names in db:

Code
UPDATE `your-database`.`prefix_joomgallery` SET `imgfilename` = REPLACE(imgfilename,'_','-')
UPDATE `your-database`.`prefix_joomgallery` SET `imgthumbname` = REPLACE(imgthumbname,'_','-')
UPDATE `your-database`.`prefix_joomgallery_catg` SET `catpath` = REPLACE(catpath,'_','-')


I'll be happy if you include that improvement in your source code.
« Last Edit: 01-07-2015 00:07:56 by siristru » Logged
MrMusic
Administrator
Hero Member
*****
Offline Offline

Posts: 1078



View Profile
« Reply #1 on: 01-07-2015 15:23:34 »

Hi,

you should suggest the code on github.
Then the developers can discuss about it.
Logged

Regards
MrMusic
Is your Problem solved? Please mark it as solved
Demo-Shop for JoomGallery Images
Pages: [1]
Print
Jump to:  

HOSTED BY SCHWARZKÜNSTLER ®

PROTECTED BY  ZB BLOCK  AND Project Honey Pot
Theme orange-lt created by panic

Bad Behavior has blocked 5535 access attempts in the last 7 days.