feat: gravatar integration
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import {Controller} from '@hotwired/stimulus'
|
||||
|
||||
export default class extends Controller {
|
||||
static values = {url: String, alt: String}
|
||||
static classes = ['image']
|
||||
|
||||
connect() {
|
||||
const img = new Image()
|
||||
img.onload = () => {
|
||||
img.classList.add(...this.imageClasses)
|
||||
this.element.innerHTML = ''
|
||||
this.element.appendChild(img)
|
||||
}
|
||||
img.alt = this.altValue
|
||||
img.src = this.urlValue
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user