Image meta retrieval quirks
-
Hello,
I have to do some maintenance on a website, upgraded this plugin (from 4.7.3 to latest 4.9.6) and I found a quite puzzling behaviour when retrieving image meta. So in short, I’ve lost the image caption display after upgrade.
The code used for displaying in frontend is:
____________________________________________________
[code]
$args=array('type'=>'image','size'=>'full');
$files = rwmb_meta( 'rw_imgsedito', $args );
...
foreach ( $files as $info )
{
...
<div>{$info['title']}</div>
<div>{$info['caption']}</div>
...
}
[/code]
____________________________________________________
The array structure of 4.7.3 is:
____________________________________________________
[code]
array(11) { ["ID"]=> string(5) "139" ["name"]=> string(72) "(...).jpg" ["path"]=> string(118) "(...)" ["url"]=> string(133) "(...)" ["width"]=> int(428) ["height"]=> int(600) ["full_url"]=> string(133) "..." ["title"]=> string(46) "..." ["caption"]=> string(80) "..." ["description"]=> string(0) "" ["alt"]=> string(0) "" }
[/code]
____________________________________________________which is fine. As stated in the documentation, the key ‘caption’ appears on first level.
After the upgrade:
____________________________________________________
[code]
array(10) { ["width"]=> int(428) ["height"]=> int(600) ["file"]=> string(80) "....jpg" ["sizes"]=> array(5) { ["thumbnail"]=> array(4) { ["file"]=> string(65) "....jpg" ["width"]=> int(150) ["height"]=> int(150) ["mime-type"]=> string(10) "image/jpeg" } ["medium"]=> array(4) { ["file"]=> string(65) "....jpg" ["width"]=> int(214) ["height"]=> int(300) ["mime-type"]=> string(10) "image/jpeg" } ["medium_large"]=> array(4) { ["file"]=> string(66) "....jpg" ["width"]=> int(768) ["height"]=> int(1077) ["mime-type"]=> string(10) "image/jpeg" } ["large"]=> array(4) { ["file"]=> string(66) "....jpg" ["width"]=> int(730) ["height"]=> int(1024) ["mime-type"]=> string(10) "image/jpeg" } ["liste-dessina"]=> array(4) { ["file"]=> string(65) "....jpg" ["width"]=> int(322) ["height"]=> int(172) ["mime-type"]=> string(10) "image/jpeg" } } ["image_meta"]=> array(12) { ["aperture"]=> string(1) "0" ["credit"]=> string(0) "" ["camera"]=> string(0) "" ["caption"]=> string(0) "" ["created_timestamp"]=> string(10) "1475571887" ["copyright"]=> string(0) "" ["focal_length"]=> string(1) "0" ["iso"]=> string(1) "0" ["shutter_speed"]=> string(1) "0" ["title"]=> string(0) "" ["orientation"]=> string(1) "1" ["keywords"]=> array(0) { } } ["ID"]=> string(5) "13965" ["name"]=> string(72) "..." ["path"]=> string(118) "..." ["url"]=> string(133) "..." ["title"]=> string(52) "..." }
[/code]
____________________________________________________It looks like the caption appears only in image_meta section, and is empty, but in the backend, the field is correctly filled!
And why does it retrieve the meta info for several sizes, as the size was explicitly stated in the function?Any pointers?
Thanks in advance.
- The topic ‘Image meta retrieval quirks’ is closed to new replies.