Author Topic: Change media image folder name  (Read 2249 times)

Offline sky writer

  • Posts: 926
Change media image folder name
« on: October 14, 2015, 09:29:14 PM »
How difficult is it to change the media/bakery image folder to something else, like media/products?

freeSbee

  • Guest
Re: Change media image folder name
« Reply #1 on: October 14, 2015, 09:57:51 PM »
Hi sky writer

You can use your favorite IDE to perform a search / replace on all Bakery files. The path is hard coded about 33 times. Search …
Code: [Select]
MEDIA_DIRECTORY.'/bakery
and replace by …
Code: [Select]
MEDIA_DIRECTORY.'/products
The main drawback of changing hard coded directory names is that you will have to redo it each time you upgrade.

Regards Christoph

Offline sky writer

  • Posts: 926
Re: Change media image folder name
« Reply #2 on: October 14, 2015, 10:21:10 PM »
Thank you Christoph.

Offline Gast

  • Posts: 5920
Re: Change media image folder name
« Reply #3 on: October 14, 2015, 10:53:58 PM »
is it not a better solution, if you define the gallery folder name in the file modules/bakery/config.php maybe with

Code: [Select]
<?php for colored code onlydont copy that line
// name of the bakery picture folder in media
$sBakeryImgFolder 'products';  //no leading/trailing slash or backslash!! A simple directory name only!!  
                       

and change

Code: [Select]
MEDIA_DIRECTORY.'/bakery/
to

Code: [Select]
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'/
??

Offline sky writer

  • Posts: 926
Re: Change media image folder name
« Reply #4 on: October 15, 2015, 06:50:23 PM »
Jacobi,

I tried your idea, because I like the thought of being able to change this folder more easily.  But the variable doesn't load in the admin (modify.php) or on the main products overview frontend page (maybe elsewhere, but I noticed these two for sure).

I took off your trailing forwardslash, because that caused the search and replace to miss some files.

replace:
Code: [Select]
MEDIA_DIRECTORY.'/bakery
with:
Code: [Select]
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'

Offline Gast

  • Posts: 5920
Re: Change media image folder name
« Reply #5 on: October 15, 2015, 10:24:40 PM »
I took off your trailing forwardslash, because that caused the search and replace to miss some files.

i test only some pages in the backend, but not all functions.  :oops:
Do you have a working solution on this basis now?

P.S.: i think, a good example must be be OneForAll-Module (if i remember correct, it have a way like this in the code)

Offline sky writer

  • Posts: 926
Re: Change media image folder name
« Reply #6 on: October 16, 2015, 02:47:02 AM »
Hi Jacobi,

I used Christoph's fix, because it works as is.  And since future upgrades will require a new search and replace with either approach, maybe this is the most sensible solution.  At least until the future possibility of something similar being implemented into the bakery core.

But I didn't given up on your idea, because I think it would be a helpful addition.

Here's what I did to get it working.

added your code to the bottom of the bakery/config.php file:
Code: [Select]
// name of the bakery image folder in media
$sBakeryImgFolder = 'products';  //no leading/trailing slash or backslash!! A simple directory name only!! 

Renamed my media/bakery folder to media/products

Did a search (Find in Files) with Notepad++ for all instances of (31 total in 8 files):
Code: [Select]
MEDIA_DIRECTORY.'/bakeryand replaced with:
Code: [Select]
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.'
There are two files which require different replace formatting
'save_item.php' ~line 278
Code: [Select]
MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.notice the difference, there is no single quote between MEDIA_DIRECTORY.'/'.$sBakeryImgFolder.   <and>   $directory;

uninstall.php ~line 52
Code: [Select]
MEDIA_DIRECTORY.'/'.$sBakeryImgFoldernotice the difference, there is no trailing single quote or concatenation.

I took a look at the OneForAll module files and the calls are to the info.php for the module name '$mod_name' - to complete the media folder path.

There are two files which aren't displaying the images in bakery with the above settings in place, modify.php and view_overview.php

I added the following to those two files (near the top, although I do not know if placement matters), and it now everything seems to work:
Code: [Select]
// Get some default values
require_once(WB_PATH.'/modules/bakery/config.php');

But I do not know enough to know if this is all something that should be done, or what effect it might have.  But it was fun working it out.

Offline Gast

  • Posts: 5920
Re: Change media image folder name
« Reply #7 on: October 16, 2015, 02:58:36 AM »
 (Y) (Y) (Y)

Thanks!!

i'll do the same over the weekend

 

postern-length