WordPress.org

Ready to get started?Download WordPress

Forums

Get available image sizes using attachment id (3 posts)

  1. darshakparmar
    Member
    Posted 1 year 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
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    Thanks buddy. I tried. works perfect :)

Topic Closed

This topic has been closed to new replies.

About this Topic