Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3853098
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:25:02+00:00 2026-05-19T17:25:02+00:00

This is in reference to this answer: Embed png image in html file using

  • 0

This is in reference to this answer: Embed png image in html file using Jinja2

Is it possible to embed the base64 encoding of my image once in the Html, but use it in many places? I can use jQuery if needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:25:03+00:00Added an answer on May 19, 2026 at 5:25 pm

    Simply put your base64 image in an IMG tag, say with an id=”logo”, then wherever you want to use it just have an IMG tag with an empty “src” attribute and a class=”logo”. Then use jQuery to set the “src” attribute for those IMGs to the master. e.g.

    jQuery:

    var src = $('img#logo').attr('src');
    $('img.logo').attr('src', src);
    

    HTML:

        ......<img id="logo" src="data:image/png;base64,
    iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGP
    C/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IA
    AAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1J
    REFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jq
    ch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0
    vr4MkhoXe0rZigAAAABJRU5ErkJggg==" alt="logo">
        ......
        ......<img class="logo" src="" alt="logo">
    

    I’m glad you asked this question as it’s something I wanted to do a couple of weeks ago in a lightbox clone (slimbox2). I wanted to embed the image in the javascript, rather than load it from a file, since the image is specific to the javascript (nice “next”, “prev”, “play”, “pause” buttons) and I did not want the user to have to store them in a specific location.

    BEWARE, this type of data is fine for IE8 and above but apparently not Internet Explorer 7 and below. See:

    http://en.wikipedia.org/wiki/Data_URI_scheme

    Regards
    Neil

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In reference to this answer to a Stack Overflow question : what is bench-testing
(Posting this question for reference purpose, I'll answer immediately) How to add header search
(I asked a variation of this question on comp.std.c++ but didn't get an answer.)
In reference to the answer of this SO question: Keeping track of changes in
This is in reference to this (excellent) answer . He states that the best
Thanks to this question/answer Automatic Reference Counting: Error with fast enumeration I resolved a
I've read this reference Using Jquery to hide/unhide the textbox if button is clicked
This is mainly in reference to this answer in Python vs Groovy vs Ruby?
With the reference of this answer , what is Theta (tight bound)? Omega is
This is with reference to using Google Contacts Data API. It requires that the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.