this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Imgur rending animations...again

+23 -11
+22 -10
internal/service/content.go
··· 165 165 if len(matches) > 1 { 166 166 id := matches[1] 167 167 ext := matches[2] 168 - // Use .jpg as default extension if none specified 168 + // Default to .mp4 for animations (Imgur's preferred animated format) 169 169 if ext == "" { 170 - ext = "jpg" 170 + ext = "mp4" 171 171 } 172 172 imgURL := fmt.Sprintf("https://i.imgur.com/%s.%s", id, ext) 173 173 174 - // Render image wrapped in IRC link handler anchor 175 - // Use visibility toggle pattern (same as gallery) to avoid race conditions 176 - // Detect Imgur placeholder by dimensions (161x81px) or true 404 errors 177 - embed := fmt.Sprintf( 178 - `<a href="%s/irclink/?%d" target="_blank" style="display: inline-block; position: relative;"> 179 - <img src="%s" class="imgur-image" 174 + var mediaTag string 175 + // Render as video tag for animated formats (.mp4, .gifv, .gif) 176 + // Render as image tag for static formats (.jpg, .jpeg, .png) 177 + if ext == "mp4" || ext == "gifv" || ext == "gif" { 178 + mediaTag = fmt.Sprintf( 179 + `<video autoplay loop muted playsinline style="width: 100%%; height: auto; display: block;"> 180 + <source src="%s" type="video/mp4" /> 181 + </video>`, imgURL) 182 + } else { 183 + // Static image with error detection 184 + mediaTag = fmt.Sprintf( 185 + `<img src="%s" class="imgur-image" 180 186 onload="if(this.naturalWidth===161 && this.naturalHeight===81){this.style.display='none'; this.nextElementSibling.style.display='inline';}" 181 187 onerror="this.style.display='none'; this.nextElementSibling.style.display='inline';" /> 182 188 <span style="display: none;"> 183 189 <span class='http-error-badge'>404</span> 184 190 <span class='missing-link'>%s</span> 185 - </span> 191 + </span>`, imgURL, item.URL) 192 + } 193 + 194 + // Wrap in IRC link handler anchor for click tracking 195 + embed := fmt.Sprintf( 196 + `<a href="%s/irclink/?%d" target="_blank" style="display: inline-block; position: relative;"> 197 + %s 186 198 </a>`, 187 - baseURL, item.ID, imgURL, item.URL) 199 + baseURL, item.ID, mediaTag) 188 200 189 201 d.Content = template.HTML(embed) 190 202 isImgur = true
+1 -1
internal/service/content_test.go
··· 170 170 wantType: "single", 171 171 wantIRCLinkHandler: true, 172 172 wantImgurCDN: true, 173 - wantErrorHandler: true, 173 + wantErrorHandler: false, // Extensionless URLs default to .mp4 video (no error handler) 174 174 wantSuppressOG: true, 175 175 }, 176 176 {