Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: shadav on June 23, 2020, 04:42:03 PM

Title: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 04:42:03 PM
not sure where to ask this so I guess graphics and templates is the best place, if not feel free to move it

so, I pretty much use the same images across all themes....
how would I edit the themes to use the images from the default theme's images folder?

so instead of having multiple files of the same image in each and every theme, I could just have one file and call it into the other themes?

the only real difference would be in the themes/images/theme folder, these would be different per theme but everything else topic/post/icons/bbc/buttons/admin/ect are all the same....
so how can I get rid of these extra (duplicate) files/folders and just use one localized file/folder

I hope that made sense and you understand what I'm getting at....

thank you

[edit] for a 2.0.17
Title: Re: How To Use A Localized Image Folder
Post by: Deaks on June 23, 2020, 04:51:11 PM
this would require quite some work on the template and source files but really depends what exact images you were thinking
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 04:57:00 PM
basically for every image it would use the images from the default theme's image folder

except for the images in the theme in use/images/theme this would be per theme
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 05:05:44 PM
had a thought

in my admin under current theme
if I change the
This theme's images URL:
from the theme's url to the default theme's url....would this work?
Title: Re: How To Use A Localized Image Folder
Post by: Deaks on June 23, 2020, 05:14:30 PM
it potentially could, not something anyone has asked before, I was thinking doing similar through repair_settings then only downside would be you would need to change every call to custom files in the custom theme
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 05:22:58 PM
All themes should fall back to default theme images if the images are missing from the custom theme, so it's worth trying changing the call to the folder. Other option would be to delete the unwanted images from the custom themes (or just rename the relevant folder as a test) and see what happens.

ETA: Oh, one trick to be aware of. At the top of index.template.php there is this:

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

So you'd probably also want to set that appropriately.
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 05:33:02 PM
well i tested it and changing the url in the admin does work but I don't think that's the way to go as then all images are from the default even the theme folder and the thumbnail
which isn't a big deal to me, I got rid of all the theme specific images like the main_block.png....only image specific is the header.png
and well it's funnier seeing in the user profile changing themes and the thumbnails all show the same image  :laugh:

and I tried that too Ant but nope, it doesn't fall back to the default image folder, there's just broken images everywhere  :laugh: :laugh:

I think what needs to be done is in all the theme template files need to change the links
for instance in boardindex.template.php
<img id="newsupshrink" src="', $settings['images_url'], '/collapse.gif" alt="*" title="', $txt['upshrink_description'], '" style="display: none;" />
needs to point to the default theme instead of using settings

or like this one
<img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'on', $board['new'] ? '' : '2', '.png" alt="', $txt['new_posts'], '" title="', $txt['new_posts'], '" />'; change the theme variant url

so then what would be the variable for the default theme or do I just need to hardcode it in there url/Themes/default/images/

[edit] just saw you edited your reply, i'll take a look at that
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 05:38:17 PM
Quote from: Antechinus on June 23, 2020, 05:22:58 PM
All themes should fall back to default theme images if the images are missing from the custom theme, so it's worth trying changing the call to the folder. Other option would be to delete the unwanted images from the custom themes (or just rename the relevant folder as a test) and see what happens.

ETA: Oh, one trick to be aware of. At the top of index.template.php there is this:

/* Use images from default theme when using templates from the default theme?
if this is 'always', images from the default theme will be used.
if this is 'defaults', images from the default theme will only be used with default templates.
if this is 'never' or isn't set at all, images from the default theme will not be used. */
$settings['use_default_images'] = 'never';

So you'd probably also want to set that appropriately.

eh that didn't work either

:laugh: :laugh: :laugh: do not change it to always.....that overwrote even the images in css  :laugh: :laugh:
default doesn't seem to do anything, but i'll leave it to default for now....
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 05:43:39 PM
Cool. We now know more things that don't work. :D That has to narrow down the solution.

Anyway, the variable for calling from the default images folder is shown in this post:

https://www.simplemachines.org/community/index.php?topic=532532.msg3784393;topicseen#msg3784393
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 06:06:48 PM
changing
$settings['images_url']
to
$settings['default_images_url']
in the theme's template files seems to work.... a few things though
need to go through any installed mods and change it there too

for some reason though the collapse image on boards still isn't working and the gender icons, oh and stars on post profile (which might be a mod)....

it's a start :)

[edit] fixed the gender icons and stars, had to change that in load.php
do not replace all instances, only the ones for those specific images (or other images that you want to use default images for and not theme related)

still not sure why the collapse image isn't working
<img id="newsupshrink" src="', $settings['default_images_url'], '/collapse.gif" alt="*" title="', $txt['upshrink_description'], '" style="display: none;" />
the image is in the default image folder....  :-\
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 06:23:59 PM
lol i know to most this isn't a big issue....
but my image folder is like 6mb times 4 themes.....I mean we're still only talking about 24mb but still, kind of annoying having multiple locations for the same file.....and well....my sites are using 16gb of disk space so every little bit of consolidation helps ;)

well it was a lot more but I went through today and smushed all my images to cut their file sizes almost in half and then was like why am I copying the same images to every theme  :laugh:
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 06:35:26 PM
The collapse image is called in javascript in the template. You'd have to change it in the js too. :)

// Define the upper_section toggle in JavaScript.
echo '
<script type="text/javascript"><!-- // --><![CDATA[
var oMainHeaderToggle = new smc_Toggle({
bToggleEnabled: true,
bCurrentlyCollapsed: ', empty($options['collapse_header']) ? 'false' : 'true', ',
aSwappableContainers: [
\'upper_section\'
],
aSwapImages: [
{
sId: \'upshrink\',
srcExpanded: smf_images_url + \'/upshrink.png\',
altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
srcCollapsed: smf_images_url + \'/upshrink2.png\',
altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
}
],
oThemeOptions: {
bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
sOptionName: \'collapse_header\',
sSessionVar: ', JavaScriptEscape($context['session_var']), ',
sSessionId: ', JavaScriptEscape($context['session_id']), '
},
oCookieOptions: {
bUseCookie: ', $context['user']['is_guest'] ? 'true' : 'false', ',
sCookieName: \'upshrink\'
}
});
// ]]></script>';


Same would apply to any other js toggle images (info centre, quick reply, etc).
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 07:10:08 PM
still can't get it to work

I changed
smf_images_url
to
default_images_url

but still it's trying to pull the image from the theme and not the default theme....gotta be missing something somewhere...

thank you for your help btw :)

as far as I can tell (aside from mods) the collapse/expand image is the only thing that isn't working
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 07:22:16 PM
Oh hang on, you mean the collapse image in the category header bars (ie: on boards). DId you catch this one, in Sources/Subs-BoardIndex.php?

Code (Line 99) Select
'collapse_image' => isset($row_board['can_collapse']) ? '<img src="' . $settings['images_url'] . '/' . $context['theme_variant_url'] . ($row_board['is_collapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' />' : '',
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 07:37:19 PM
Quote from: Antechinus on June 23, 2020, 07:22:16 PM
Oh hang on, you mean the collapse image in the category header bars (ie: on boards). DId you catch this one, in Sources/Subs-BoardIndex.php?

Code (Line 99) Select
'collapse_image' => isset($row_board['can_collapse']) ? '<img src="' . $settings['images_url'] . '/' . $context['theme_variant_url'] . ($row_board['is_collapsed'] > 0 ? 'expand.gif" alt="+"' : 'collapse.gif" alt="-"') . ' />' : '',

that did the trick  ;D
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 08:04:26 PM
thank you, I'm going to mark this as solved as I'm pretty sure everything is working now
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 08:12:27 PM
Cool. Handy to refresh my memory of where all this stuff hides. I tend to want to do unusual things every so often. :)
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 23, 2020, 08:41:38 PM
just as a side note
I deleted all of the files out of the theme's image folder
except for the theme folder (or custom folder that's in one of the themes) and the thumbnail.gif
this way I can keep where needed links to theme specific images and then change everything else to use the default images
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 23, 2020, 09:24:03 PM
Makes sense.
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 24, 2020, 03:31:08 PM
ok ran into a slight snag  :laugh:
I forgot to edit the css

on one site I got rid of the theme folder as they were the same images (I just made the same theme in different colors)....so then had to edit the css to point any
../images
to
../../default/images

other than that, I think everything is sorted now  ;D
Title: Re: How To Use A Localized Image Folder
Post by: Kindred on June 24, 2020, 04:26:14 PM
just as a pedantic note...   what you actually meant was "how do I set a centralized image folder" -- because "localized" would mean (in web terms) a separate image folder for each language :D
Title: Re: How To Use A Localized Image Folder
Post by: Deaks on June 24, 2020, 04:28:06 PM
for you maybe for me I thought they wanted it hosted on their computer till i read the post
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 24, 2020, 04:31:39 PM
 :laugh: thanks, yeah I wasn't sure how to word that....

ran into another snag, but that's that theme....can't figure out where the menu file is at
the main menu icons are showing but the sub menus aren't and I'm not sure why, it keeps trying to pull the image from the theme folder instead of the default theme folder....fairly sure i've changed everything over....

it's a recolor of the nightbreeze theme, gonna go ask in their support, maybe they can help....
Title: Re: How To Use A Localized Image Folder
Post by: Deaks on June 24, 2020, 04:36:48 PM
if its default menu it be subs.php but without looking at theme check very bottom of the index.template.php
Title: Re: How To Use A Localized Image Folder
Post by: SychO on June 24, 2020, 04:39:29 PM
NightBreeze does not use image icons for the menu, it uses FontAweome icons which are not images. So I do not know what you mean by menu file.
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 24, 2020, 04:59:03 PM
hm, ok :) well then that at least points me into the right direction to work on that :)


also found a few others needed changing

$settings['theme_url'], '/images/
to
$settings['default_images_url'].'/
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 24, 2020, 05:21:47 PM
This will keep you amused for weeks. :D
Title: Re: How To Use A Localized Image Folder
Post by: Deaks on June 24, 2020, 05:23:46 PM
shadav I found aboout 470 images_url when I searched the other day :D
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 24, 2020, 05:26:56 PM
Quote from: Deaks on June 24, 2020, 04:36:48 PM
if its default menu it be subs.php but without looking at theme check very bottom of the index.template.php

Quote from: SychO on June 24, 2020, 04:39:29 PM
NightBreeze does not use image icons for the menu, it uses FontAweome icons which are not images. So I do not know what you mean by menu file.

ok got it...it was a mod that I had installed that added icons to the menu and it was the subs.php


thank you again to all of you for your help :)
really I think this time it's all working (I need to stop jinxing myself)

Quote from: Antechinus on June 24, 2020, 05:21:47 PM
This will keep you amused for weeks. :D

:laugh: :laugh: :laugh:
eh but it's worth it
well until I try to upgrade or update your theme..... lmfao *throws my hands in the air* I QUIT  :laugh: :laugh: :laugh:

Quote from: Deaks on June 24, 2020, 05:23:46 PM
shadav I found aboout 470 images_url when I searched the other day :D

bwahahahahahaha I believe that too.... I've not been keeping track but yeah there's a lot (multiplied by however many themes one uses)
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 24, 2020, 05:46:52 PM
I suppose I could update my old Curve variants with basic responsive behaviour, similar to how I did the dark theme for this site. Wouldn't be as flash as the Mutant, but would be more mod-friendly (as long as said mods weren't trying to search for bits of default CSS, because that would really screw them up :) ).
Title: Re: How To Use A Localized Image Folder
Post by: shadav on June 24, 2020, 07:32:56 PM
 :laugh: :laugh: :laugh: ant  :laugh: :laugh: :laugh:
I like all of the
/*
Redundant file.
*/

in the mutant css :laugh: :laugh: :laugh:
Title: Re: How To Use A Localized Image Folder
Post by: Antechinus on June 24, 2020, 07:45:59 PM
Oh yeah. Those things haven't been required for years, but I left them in as blank files just in case Sources wanted to throw a tanty if it missed one of them. Beats chasing down weird bugz.