Skip to content

Fix broken preview images for extension-less external files - #1520

Open
killecaptron wants to merge 1 commit into
Part-DB:masterfrom
killecaptron:fix-attachment-picture-detection
Open

Fix broken preview images for extension-less external files#1520
killecaptron wants to merge 1 commit into
Part-DB:masterfrom
killecaptron:fix-attachment-picture-detection

Conversation

@killecaptron

Copy link
Copy Markdown

If no file extension can be extracted from the URL of an external attachment, Part-DB assumed that it is a picture. That is a sensible guess for image URLs, but it also applies to URLs which redirect to the actual file, like the datasheet links of the TrustedParts provider (https://www.trustedparts.com/productredirect?id=...).

Such datasheets were rendered as an in the attachment lists (showing a broken image) and the first one was automatically used as the preview picture of the part by the AttachmentSubmitHandler, so the part page showed a broken main image too.

The attachment type already knows which filetypes it may contain (the "Datasheet" type created by the info provider system is restricted to application/pdf), so use that information for the guess. Attachments whose URL has a known picture extension are unaffected, as are attachment types without a filetype filter.

Existing parts heal themselves: the AttachmentSubmitHandler already removes a master picture attachment which is not a picture anymore, as soon as the part is saved the next time.

If no file extension can be extracted from the URL of an external
attachment, Part-DB assumed that it is a picture. That is a sensible
guess for image URLs, but it also applies to URLs which redirect to the
actual file, like the datasheet links of the TrustedParts provider
(https://www.trustedparts.com/productredirect?id=...).

Such datasheets were rendered as an <img> in the attachment lists
(showing a broken image) and the first one was automatically used as the
preview picture of the part by the AttachmentSubmitHandler, so the part
page showed a broken main image too.

The attachment type already knows which filetypes it may contain (the
"Datasheet" type created by the info provider system is restricted to
application/pdf), so use that information for the guess. Attachments
whose URL has a known picture extension are unaffected, as are
attachment types without a filetype filter.

Existing parts heal themselves: the AttachmentSubmitHandler already
removes a master picture attachment which is not a picture anymore, as
soon as the part is saved the next time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant