mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #882] How to add an image to the Captive Portal? #745
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#745
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gitnwana on GitHub (May 8, 2019).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/882
Description
I've been trying to add an image to the captive portal of the library, but can't. I've tried modifying the source file by adding another variable parameter for the image but it doesn't seem to work. Any help will be appreciated.
@CanerSonmez commented on GitHub (May 11, 2019):
you can use this link https://www.base64-image.de , your image should be base64 format then
add this code:
#logo {background:url('your base64 format') }
@gitnwana commented on GitHub (May 13, 2019):
Do I add this in the source file or my Arduino script?
@CanerSonmez commented on GitHub (May 14, 2019):
you should examine the WifiManager.h for this and you will see how to do this
@gitnwana commented on GitHub (May 30, 2019):
@CanerSonmez I tried that it still doesn't work.
@xtech007 commented on GitHub (Apr 5, 2020):
Hi!
has anyone been able to add an image to the Wifimanager?
If so, can you show how and where to do it correctly. The image convertion I understand why it has to be this way, but where do add it?
On the WifiManager.h under;
const char HTTP_STYLE[] PROGMEM there is a line that its kinda similar to what CanerSonmez commented,
.l{background: url('data:image/png;base64,DATA') no-repeat left center;background-size: 1em}
I have no coding experience and so far what I have learned is based on guides and awesome forums like this one!
Any guides are appreciated!
@bwjohns4 commented on GitHub (Apr 5, 2020):
Here is how I was able to add a logo. You'll to to use search/find to find the relevant places in these files to make additions. I think this covers everything I did to get this to work. Mine definitely work, let me know if this gives you any trouble.
I added include image.h right after the HTTP_END[] line where all the HTML is specified:
I just used http://tomeko.net/online_tools/file_to_hex.php?lang=en and made a separate image.h file in the same directory as WiFiManager with these contents:
Then added a prototype in this section:
Modifications to the cpp file
Also added this function to send the logo when the html requests it. Put it near the other handleXXX() functions.
Finally, I added the server->on piece to the section below to register the handleLogo() function to be called to supply the logo file:
@xtech007 commented on GitHub (Apr 6, 2020):
bwjohns4, I will definitely try it sometime today!
Thank you 🙏 so much for the guide, and sample.
Do you have it working?
Can we see the results?
@dknop97 commented on GitHub (Apr 7, 2020):
I don't have a model to show this, sorry... but in a near past, I has used images in the header of the Captive Portal. To do this, I just copied all de HTML of the WiFiManager.h, inside the variables HTTP_HEADER, HTTP_STYLE, HTTP_SCRIPT, HTTP_HEADER_END, ..., HTTP_END, and make a normal HTML file. So, I put my image in the same folder of the sketch, format my image were I want in the portal and return the HTML to the variables in the WiFiManager.h, following the original fragmentation of the HTML in the this variables.
This tatical has been used in the #999 issue to, were I made a similar indication.
Sorry about my English, I'm improving it yet 😄
@tablatronix commented on GitHub (Apr 7, 2020):
Just use the development branch and change the html in strings.h
base64 encode the image or use svg
@tablatronix commented on GitHub (Apr 7, 2020):
@Munnu62 commented on GitHub (Apr 14, 2020):
@tablatronix Hey, I've tried but I couldn't able to load the image in my web portal! Same procedure has been followed! In string_en.h Changes as been told in HTTP_ROOT_MAIN[] but, Couldn't able to load image in web portal! using base64 image! I've tried above code with my system, It's working fine, But as I try to upload my logo, it didn't respond to that!
@Munnu62 commented on GitHub (Apr 14, 2020):
Here's Screenshot!
@tablatronix commented on GitHub (Apr 14, 2020):
open ip in a browser and use development mode to see what the code is spitting out?
Does the sample I posted above work if you uncomment it ?
@sohaibilyas commented on GitHub (Sep 9, 2020):
@tablatronix you mentioned to simply update strings.h but next time if library is updates it overwrites strings.h so is there any better way to update html without changing library files, thanks.
@tablatronix commented on GitHub (Sep 10, 2020):
Not at this time
@joko2020 commented on GitHub (Jul 18, 2021):
I do like instruction from @tablatronix as follow

@tablatronix Thanks .... for me it's work fine, but I don't know how to justify the img relative to center of screen.