Home Forums General Issues adding a class to image attachment Reply To: adding a class to image attachment

  • OK Found it.

    As per the Code reference, the function uses four values:

    wp_get_attachment_image( int $attachment_id, string|array $size = 'thumbnail', bool $icon = false, string|array $attr = '' )

    Where I use only three. If I add the fourth value like so:

    echo wp_get_attachment_image($image, $size, "",array('class' => 'rounded-top') );

    It works. So problem solved.

    What makes it hard to spot the fault is that WP seems to use four values where in this case the four values seem required?

    Anyway, thanks for looking into this and pointing me toward the code reference.