Is there a way to display an icon file in a page, with a specific size selected?

StackOverflow https://stackoverflow.com/questions/21687078

  •  09-10-2022
  •  | 
  •  

سؤال

My company's site has a series of subdomains for their customers, and most of the subdomains have a unique favicon associated with them. Up until recently, we would manually upload any new favicons. I'm working on moving favicon support to where our system admin can upload + assign them by web form.

We have a table of a few hundred subdomains, and I'd like to display the favicon as a preview in an html table, on the same row as the subdomain it is associated with.

Is there a way to display the .ico files in image tags? If the .ico has multiple sizes (we usually do 64x, 32x, and 16x pixel sizes), is there a way to specify which size to display?

Some research I did suggested that IE doesn't display them while other browsers do, but it was unclear whether that was as a favicon, or as an image in the page.

هل كانت مفيدة؟

المحلول 2

I've had some success just putting the file's path in an <img> tag like any other image, and specifying the width and height desired. I'm not sure whether the 16x16 size would be used if I specify width and height of 16, or if it uses the largest size and scales it down.

نصائح أخرى

I think your best bet here is to convert the .ico files to something like a jpg or png and store them. Then you can reference the jpg or png version of the icon. I don't believe there is a 100% perfect way to display .ico that will work cross-browser compatible.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top