What is the “icon” parameter in wp_get_attachment_image_src used for?

On the reference page for wp_get_attachment_image_src, there is a parameter called icon and it only says:

$icon - (bool) (optional) Use a media icon to represent the attachment. 
Default: false

What is this used for and how does it affect the returned value?

1 Answer
1

It’s a icon with which to display the attachment. If it isn’t set, it uses the default icon. The exception here is for images: the returned values always refer to the thumbnail (of size set in the arguments of wp_get_attachment_image_src). Icons are always shown at their original size.

If the attachment was an audio file, it would use the audio icon, unless otherwise specified using the icon argument. See the ‘Change Icon Directory’ section of the link you gave in the question.

Leave a Comment