forked from indymedia/epicyon
Allow different background file formats
parent
10b9f2818d
commit
2dca999231
Binary file not shown.
After Width: | Height: | Size: 98 KiB |
51
theme.py
51
theme.py
|
@ -608,6 +608,7 @@ def setThemeImages(baseDir: str, name: str) -> None:
|
||||||
|
|
||||||
backgroundNames = ('login', 'shares', 'delete', 'follow',
|
backgroundNames = ('login', 'shares', 'delete', 'follow',
|
||||||
'options', 'block', 'search', 'calendar')
|
'options', 'block', 'search', 'calendar')
|
||||||
|
extensions = ('png', 'jpg', 'gif')
|
||||||
|
|
||||||
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
for subdir, dirs, files in os.walk(baseDir + '/accounts'):
|
||||||
for acct in dirs:
|
for acct in dirs:
|
||||||
|
@ -619,28 +620,36 @@ def setThemeImages(baseDir: str, name: str) -> None:
|
||||||
os.path.join(baseDir + '/accounts', acct)
|
os.path.join(baseDir + '/accounts', acct)
|
||||||
|
|
||||||
for backgroundType in backgroundNames:
|
for backgroundType in backgroundNames:
|
||||||
if themeNameLower == 'default':
|
for ext in extensions:
|
||||||
backgroundImageFilename = \
|
if themeNameLower == 'default':
|
||||||
baseDir + '/img/' + backgroundType + '-background.png'
|
backgroundImageFilename = \
|
||||||
else:
|
baseDir + '/img/' + backgroundType + \
|
||||||
backgroundImageFilename = \
|
'-background.' + ext
|
||||||
baseDir + '/img/' + backgroundType + '_background_' + \
|
else:
|
||||||
themeNameLower + '.png'
|
backgroundImageFilename = \
|
||||||
|
baseDir + '/img/' + backgroundType + \
|
||||||
|
'_background_' + \
|
||||||
|
themeNameLower + '.' + ext
|
||||||
|
|
||||||
if os.path.isfile(backgroundImageFilename):
|
if os.path.isfile(backgroundImageFilename):
|
||||||
try:
|
try:
|
||||||
copyfile(backgroundImageFilename,
|
copyfile(backgroundImageFilename,
|
||||||
baseDir + '/accounts/' + backgroundType +
|
baseDir + '/accounts/' + backgroundType +
|
||||||
'-background.png')
|
'-background.' + ext)
|
||||||
except BaseException:
|
break
|
||||||
pass
|
except BaseException:
|
||||||
elif os.path.isfile(baseDir + '/accounts/' + backgroundType +
|
pass
|
||||||
'-background.png'):
|
# background image was not found
|
||||||
try:
|
# so remove any existing file
|
||||||
os.remove(baseDir + '/accounts/' + backgroundType +
|
if os.path.isfile(baseDir + '/accounts/' +
|
||||||
'-background.png')
|
backgroundType +
|
||||||
except BaseException:
|
'-background.' + ext):
|
||||||
pass
|
try:
|
||||||
|
os.remove(baseDir + '/accounts/' +
|
||||||
|
backgroundType +
|
||||||
|
'-background.' + ext)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
if os.path.isfile(profileImageFilename) and \
|
if os.path.isfile(profileImageFilename) and \
|
||||||
os.path.isfile(bannerFilename):
|
os.path.isfile(bannerFilename):
|
||||||
|
|
Loading…
Reference in New Issue