Merge pull request 'Fix image zoom URL handling to remove width and height parameters instead of all search params' (#50) from BordedDev/snek:bugfix/fix-image-zoom-url into main
Reviewed-on: retoor/snek#50 Reviewed-by: retoor <retoor@noreply@molodetz.nl>
This commit is contained in:
		
						commit
						24ddd4b294
					
				| @ -23,15 +23,23 @@ class MessageList extends HTMLElement { | |||||||
|     const messagesContainer = this |     const messagesContainer = this | ||||||
|       messagesContainer.addEventListener('click', (e) => { |       messagesContainer.addEventListener('click', (e) => { | ||||||
|         if (e.target.tagName !== 'IMG' || e.target.classList.contains('avatar-img')) return; |         if (e.target.tagName !== 'IMG' || e.target.classList.contains('avatar-img')) return; | ||||||
|  | 
 | ||||||
|         const img = e.target; |         const img = e.target; | ||||||
|  | 
 | ||||||
|         const overlay = document.createElement('div'); |         const overlay = document.createElement('div'); | ||||||
|         overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);display:flex;justify-content:center;align-items:center;z-index:9999;' |         overlay.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);display:flex;justify-content:center;align-items:center;z-index:9999;' | ||||||
|  | 
 | ||||||
|  |         const urlObj = new URL(img.currentSrc || img.src) | ||||||
|  |         urlObj.searchParams.delete("width"); | ||||||
|  |         urlObj.searchParams.delete("height"); | ||||||
|  | 
 | ||||||
|         const fullImg = document.createElement('img'); |         const fullImg = document.createElement('img'); | ||||||
|         const urlObj = new URL(img.src); urlObj.search = ''; | 
 | ||||||
|         fullImg.src = urlObj.toString(); |         fullImg.src = urlObj.toString(); | ||||||
|         fullImg.alt = img.alt; |         fullImg.alt = img.alt; | ||||||
|         fullImg.style.maxWidth = '90%'; |         fullImg.style.maxWidth = '90%'; | ||||||
|         fullImg.style.maxHeight = '90%'; |         fullImg.style.maxHeight = '90%'; | ||||||
|  | 
 | ||||||
|         overlay.appendChild(fullImg); |         overlay.appendChild(fullImg); | ||||||
|         document.body.appendChild(overlay); |         document.body.appendChild(overlay); | ||||||
|         overlay.addEventListener('click', () => document.body.removeChild(overlay)); |         overlay.addEventListener('click', () => document.body.removeChild(overlay)); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user