Skip to content

Instantly share code, notes, and snippets.

@digitalbocca
Last active February 2, 2019 16:58
Show Gist options
  • Save digitalbocca/d2ce586fb54b5079eb3c2ec754c6137f to your computer and use it in GitHub Desktop.
Save digitalbocca/d2ce586fb54b5079eb3c2ec754c6137f to your computer and use it in GitHub Desktop.
Snnipets de Código para ImagemBase64 (https://github.com/digitalbocca/ImagemBase64)
<img src="caminho/para/logo.php">
<div id="imagem"></div>
// INICIO DO CODIGO ZEPTO
$(document).ready(() => {
  // GET PARA A API
  $.getJSON('https://api.jsonbin.io/b/5a2311793cc482364837a119', resposta => {
    // CRIA UM OBJETO IMAGEM
    let imagem = new Image()
    // COLOCA O JSON RECEBIDO NO SRC DO OBJETO
    imagem.src = 'data:image/png;base64,' + resposta.imagem
    // INSERE A IMAGEM NA DIV
    $('#imagem').append(imagem)
    // APROVEITE PARA ADICIONAR AS CLASSES CSS SE PRECISAR
    $('#imagem > img').addClass('img-fluid')
    // NÃO ESQUEÇA DE DEFINIR UM ALT PARA SUA IMAGEM
    $('#imagem > img').attr("alt","Logo EDB 2017")
  })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment