Custom Fields
Re-Envisioned
Support MB REST API How to show image url with folder in all sizes from Rest API

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 1 week, 1 day ago.

  • Creator
    Topic
  • #16391

    PTiCA
    Participant

    I use the rest api plugin and metabox type “image_advanced”. Everything works fine, I just need to display URL images in all sizes with the complete url “/folder/image.jpg”.

    How do I do this?

    Thanks for advice

    rest api sizes

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #16412

    Anh Tran
    Keymaster

    Hi,

    You should transform the data from the REST response. Here is the example:

    $data = your_function_to_get_data_from_REST();
    $file = $data['file'];
    $folder = str_replace( basename( $file ), '', $file );
    $sizes = $data['sizes'];
    foreach ( $sizes as &$size ) {
        $size['file'] = $folder . $size['file'];
    }
    var_dump( $sizes ); // Now you have folder in your URL
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.