Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle custom logos better #60

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ button#maintenance{
margin: 5px;
}

img.logo {
width: 200px;
height: 55px;
}

#status-container{
width: 294px;
height: 125px;
Expand Down Expand Up @@ -691,14 +686,19 @@ img.logo {
display: block;
margin-left: 4px;
margin-top: 5px;
width: 250px;
width: 260px;
text-align: left;
}

#logo-container{
margin-top: 0px;
}

img.logo{
display: block;
max-width:250px;
max-height:70px;
width: auto;
height: auto;
}

span.beer-name-container{
font-size: 0.8em;
}
Expand Down
137 changes: 130 additions & 7 deletions top-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,142 @@
* You should have received a copy of the GNU General Public License
* along with BrewPi WWW RMX. If not, see <https://www.gnu.org/licenses/>.
*/

$mimetypes = array(
"image/bmp",
"image/cmu-raster",
"image/fif",
"image/florian",
"image/g3fax",
"image/gif",
"image/ief",
"image/jpeg",
"image/jutvision",
"image/naplps",
"image/pict",
"image/pjpeg",
"image/png",
"image/tiff",
"image/vasa",
"image/vnd.dwg",
"image/vnd.fpx",
"image/vnd.net-fpx",
"image/vnd.rn-realflash",
"image/vnd.rn-realpix",
"image/vnd.wap.wbmp",
"image/vnd.xiff",
"image/xbm",
"image/x-cmu-raster",
"image/x-dwg",
"image/x-icon",
"image/x-jg",
"image/x-jps",
"image/x-niff",
"image/x-pcx",
"image/x-pict",
"image/xpm",
"image/x-portable-anymap",
"image/x-portable-bitmap",
"image/x-portable-graymap",
"image/x-portable-greymap",
"image/x-portable-pixmap",
"image/x-quicktime",
"image/x-rgb",
"image/x-tiff",
"image/x-windows-bmp",
"image/x-xbitmap",
"image/x-xbm",
"image/x-xpixmap",
"image/x-xwd",
"image/x-xwindowdump"
);

$mimeexts = array(
".art",
".bm",
".bmp",
".dwg",
".dxf",
".fif",
".flo",
".fpx",
".g3",
".gif",
".ico",
".ief",
".iefs",
".jfif",
".jfif-tbnl",
".jpe",
".jpeg",
".jpg",
".jps",
".jut",
".mcf",
".nap",
".naplps",
".nif",
".niff",
".pbm",
".pct",
".pcx",
".pgm",
".pic",
".pict",
".pm",
".png",
".pnm",
".ppm",
".qif",
".qti",
".qtif",
".ras",
".rast",
".rf",
".rgb",
".rp",
".svf",
".tif",
".tiff",
".turbot",
".wbmp",
".xbm",
".xif",
".xpm",
".x-png",
".xwd"
);

// Grab the custom logo if it exists, otherwise use the stock one
$custom_logo = glob('images/custom_logo.*');
$logo = (count($custom_logo) ? $custom_logo[0] : 'images/brewpi_logo.png');
// Get site root url
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';

?>

<div class="header-grid-container ui-widget ui-widget-header ui-corner-all" id="top-bar">

<div class="logo">
<?php
// Get site root url
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
// Get logo name (use custom if it exists)
$logo = (file_exists('images/custom_logo.png') ? 'images/custom_logo.png' : 'images/brewpi_logo.png');
// Use link on logo if we are multi-chamber
$logo = ($chamber == '' ? '<img class="logo" src="' . $logo . '">' : '<a href="' . $root . '"><img class="logo" src="' . $logo . '"></a>');
echo $logo;
if (file_exists($logo)) {
// Get some additional information about the logo file
$filemime = mime_content_type($logo);
$fileext = pathinfo($logo, PATHINFO_EXTENSION);
// Check to make sure the logo is a valid image
if (in_array ($filemime, $mimetypes) && in_array ("." . $fileext, $mimeexts)) {
// Use chamber path as link on logo if we are multi-chamber
$logo_code = ($chamber == '' ? '<img class="logo" src="' . $logo . '">' : '<a href="' . $root . '"><img class="logo" src="' . $logo . '"></a>');
// Logo will be resized by CSS
echo $logo_code;
} else {
echo $logo . " is invalid";
error_log($logo . " is an invalid image.");
}
} else {
echo "Missing " . $logo;
error_log($logo . " not found.");
}
?>
</div>

Expand Down