0

Very new to php. i have the following var_dump($largeImage) that has the below output.

I'm trying to get the thumbnail url.

I have tried

$tempLargeImage = $largeImage["url"];
$overlayImage = $tempLargeImage["thumbnail"];

But this i get " Illegal string offset 'thumbnail' in"

    array(10) { 
["id"]=> int(440) ["alt"]=> string(0) "" ["title"]=> string(40) "bcd8d0b4d2d97f1889d7fab5d82075d07bfb51e8" ["caption"]=> string(0) "" ["description"]=> string(0) "" ["mime_type"]=> string(10) "image/jpeg" ["url"]=> string(112) "http://a.com/.jpg" ["width"]=> int(1589) ["height"]=> int(2048) ["sizes"]=> array(48) 
{ ["thumbnail"]=> string(120) "http://a.com/-150x150.jpg" ["thumbnail-width"]=> int(150) ["thumbnail-height"]=> int(150) ["medium"]=> string(120) "http://a.com/-233x300.jpg" ["medium-width"]=> int(233) ["medium-height"]=> int(300) ["medium_large"]=> string(112) "http://a.com/.jpg" ["medium_large-width"]=> int(1589) ["medium_large-height"]=> int(2048) ["large"]=> string(121) "http://a.com/-795x1024.jpg" ["large-width"]=> int(795) ["large-height"]=> int(1024) ["portfolio-square"]=> string(120) "http://a.com/-570x570.jpg" ["portfolio-square-width"]=> int(570) ["portfolio-square-height"]=> int(570) ["portfolio-portrait"]=> string(120) "http://a.com/-600x800.jpg" ["portfolio-portrait-width"]=> int(600) ["portfolio-portrait-height"]=> int(800) ["portfolio-landscape"]=> string(120) "http://a.com/-800x600.jpg" ["portfolio-landscape-width"]=> int(800) ["portfolio-landscape-height"]=> int(600) ["menu-featured-post"]=> string(120) "http://a.com/-345x198.jpg" ["menu-featured-post-width"]=> int(345) ["menu-featured-post-height"]=> int(198) ["qode-carousel_slider"]=> string(120) "http://a.com/-400x260.jpg" ["qode-carousel_slider-width"]=> int(400) ["qode-carousel_slider-height"]=> int(260) ["portfolio_slider"]=> string(120) "http://a.com/-500x380.jpg" ["portfolio_slider-width"]=> int(500) ["portfolio_slider-height"]=> int(380) ["portfolio_masonry_regular"]=> string(120) "http://a.com/-500x500.jpg" ["portfolio_masonry_regular-width"]=> int(500) ["portfolio_masonry_regular-height"]=> int(500) ["portfolio_masonry_wide"]=> string(121) "http://a.com/-1000x500.jpg" ["portfolio_masonry_wide-width"]=> int(1000) ["portfolio_masonry_wide-height"]=> int(500) ["portfolio_masonry_tall"]=> string(121) "http://a.com/-500x1000.jpg" ["portfolio_masonry_tall-width"]=> int(500) ["portfolio_masonry_tall-height"]=> int(1000) ["portfolio_masonry_large"]=> string(122) "http://a.com/-1000x1000.jpg" ["portfolio_masonry_large-width"]=> int(1000) ["portfolio_masonry_large-height"]=> int(1000) ["portfolio_masonry_with_space"]=> string(120) "http://a.com/-700x902.jpg" ["portfolio_masonry_with_space-width"]=> int(700) ["portfolio_masonry_with_space-height"]=> int(902) ["latest_post_boxes"]=> string(120) "http://a.com/-539x303.jpg" ["latest_post_boxes-width"]=> int(539) ["latest_post_boxes-height"]=> int(303) } 

}
1

because you have two array the second array is nested within the first

you must get the image url from the sizes array not from first array directly

$overlayImage = $tempLargeImage["sizes"]["thumbnail"];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.