Get available image sizes using attachment id (3 posts)

  1. darshakparmar
    Posted 3 years ago #

    I have been trying to write a function that adds links to available image sizes below each inserted image in a post.

    I know there is a function get_intermediate_image_sizes but it works only within a Loop for attachment pages.

    I need a function that allows me to fetch available image sizes using image id as argument. Can anyone suggest a way out?

  2. bcworkz
    Posted 3 years ago #

    Try wp_get_attachment_image_src(). You'll have to call it for each registered size, which is easily done with an array of sizes feeding a foreach loop. Otherwise it returns everything you need.

  3. darshakparmar
    Posted 3 years ago #

    Thanks buddy. I tried. works perfect :)

Topic Closed

This topic has been closed to new replies.

About this Topic