diff --git a/publisher.go b/publisher.go index fb02eed..06edec0 100644 --- a/publisher.go +++ b/publisher.go @@ -556,7 +556,20 @@ func (p *Publisher) fetchAndUploadImage(session *PDSSession, imageURL string) *B return result.Blob } +// upgradeImageURL attempts to get a larger version of known CDN image URLs +func upgradeImageURL(imageURL string) string { + // BBC images: /standard/240/ -> /standard/800/ + if strings.Contains(imageURL, "ichef.bbci.co.uk") { + imageURL = strings.Replace(imageURL, "/standard/240/", "/standard/800/", 1) + imageURL = strings.Replace(imageURL, "/standard/480/", "/standard/800/", 1) + } + return imageURL +} + func (p *Publisher) fetchAndUploadImageWithDimensions(session *PDSSession, imageURL string) *ImageUploadResult { + // Upgrade image URL to larger size if possible + imageURL = upgradeImageURL(imageURL) + // Fetch the image resp, err := p.httpClient.Get(imageURL) if err != nil {