Closed daprice closed 9 months ago
Hey @daprice! Thanks for getting in touch. This is a great point and an oversight on my behalf. I'll be looking to implement this over the next week or so.
Hey @daprice - just want to reach out and apologise for not getting onto this earlier. Looking at this now and will post any updates here.
No worries @will-lumley, I’m just thankful this exists at all!
My pleasure @daprice. Just to keep you in the loop, tonight FaviconFinder 5.0.0 will come out.
Significant refactoring has occurred for its internals, and it also has a much more developer-friendly API (in my opinion at least). You'll be able to grab all the Favicon's for a specified source, choose to download them if you want, and you can get the largest image by default, or the smallest, etc. The sizes for all the images fetched will also be a part of a property so you can tell for what sized view they might be most appropriate for.
I'll link the PR to this issue so you get a notification for it and can see when it's available :)
@daprice The PR is up. Once this PR is merged, you can get an array of FaviconURL
s for a particular URL. This is what a FaviconURL
looks like.
public struct FaviconURL {
/// The url of the .ico or HTML page, of where the favicon was found
public let source: URL
/// The type of favicon we extracted
public let format: FaviconFormatType
/// The source type of the favicon we extracted
public let sourceType: FaviconSourceType
/// If the icon is from HTML/WAMF and we've been told it's size, we'll store that data here
public let sizeTag: String?
}
If the HTML tag has it listed, the sizeTag
property will have whatever was in the HTML for that particular icon. This should help you determine what size the image should be used for.
Would love to hear your thoughts.
This issue is closed because the PR is merged - but feel free to post any thoughts you have here still :)
Thanks, this is great! Including the sizeTag
gives me all the flexibility I could ask for.
One minor documentation issue: the docs say FaviconURL.source
is the URL of the page where it was found, but it looks like it’s actually the URL of the favicon image file itself? In my case the URL of the image file is what I need, so it works as is, but it’s not what the docs say unless I’m misunderstanding something.
It’s pretty common for sites to offer multiple resolutions of each favicon type – for example https://mastodon.social/ has 11 different sizes of
apple-touch-icon
and 3 oficon
.It’s not clear which one FaviconFinder returns or if there’s any way to control it. For mastodon.social it looks like it gives me the largest available
icon
but the smallestapple-touch-icon
. I’d love to be able to either:sizes
HTML attribute so I can use them dynamically based on the size of my views.