Closed iamake closed 6 years ago
@iamake
This should be fixed now: https://github.com/ramsaylanier/WordExpressSchema/commit/551b148338fedad6a82a49143dd0cfdc3d406643#diff-30d779fe5addd3dbba2f8718b6a1c3e3
I've published a patch to npm - v4.2.1.
Hi @ramsaylanier
Thanks for the fix and fast response. That fixed the first issue but not the second.
On the sceond issue
Should have considered the case where wp_postmeta[0] and wp_postmeta[1] is not _wp_attached_file and _wp_attachment_metadata
Line 7-8 of the code assumes file
and fileMeta
are at array index 0 and 1 respectively which this is not always the case.
Can you provide me an example where this is not the case?
I inserted these 4 lines below at line 9
console.log(thumbnail[wp_prefix + 'postmeta'][0].dataValues.meta_key)
console.log(thumbnail[wp_prefix + 'postmeta'][0].dataValues.meta_value)
console.log(thumbnail[wp_prefix + 'postmeta'][1].dataValues.meta_key)
console.log(thumbnail[wp_prefix + 'postmeta'][1].dataValues.meta_value)
And here is the result of 2 different wp_posts from the dataset in my database.
_wp_attached_file
2018/02/Aw.article-180221-Digitalization-800x420.jpg
_wp_attachment_metadata
a:5:{s:5:"width";i:800;s:6:"height";i:420;s:4:"file";s:52:"2018/02/Aw.article-180221-Digitalization-800x420.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:4:{s:4:"file";s:52:"Aw.article-180221-Digitalization-800x420-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:52:"Aw.article-180221-Digitalization-800x420-300x158.jpg";s:5:"width";i:300;s:6:"height";i:158;s:9:"mime-type";s:10:"image/jpeg";}s:12:"medium_large";a:4:{s:4:"file";s:52:"Aw.article-180221-Digitalization-800x420-768x403.jpg";s:5:"width";i:768;s:6:"height";i:403;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:52:"Aw.article-180221-Digitalization-800x420-760x400.jpg";s:5:"width";i:760;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:14:"kale-thumbnail";a:4:{s:4:"file";s:52:"Aw.article-180221-Digitalization-800x420-760x400.jpg";s:5:"width";i:760;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
_wp_attachment_metadata
a:5:{s:5:"width";i:800;s:6:"height";i:420;s:4:"file";s:44:"2018/02/Aw.Article-180221-Channel-one-31.jpg";s:5:"sizes";a:5:{s:9:"thumbnail";a:4:{s:4:"file";s:44:"Aw.Article-180221-Channel-one-31-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:6:"medium";a:4:{s:4:"file";s:44:"Aw.Article-180221-Channel-one-31-300x158.jpg";s:5:"width";i:300;s:6:"height";i:158;s:9:"mime-type";s:10:"image/jpeg";}s:12:"medium_large";a:4:{s:4:"file";s:44:"Aw.Article-180221-Channel-one-31-768x403.jpg";s:5:"width";i:768;s:6:"height";i:403;s:9:"mime-type";s:10:"image/jpeg";}s:14:"post-thumbnail";a:4:{s:4:"file";s:44:"Aw.Article-180221-Channel-one-31-760x400.jpg";s:5:"width";i:760;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}s:14:"kale-thumbnail";a:4:{s:4:"file";s:44:"Aw.Article-180221-Channel-one-31-760x400.jpg";s:5:"width";i:760;s:6:"height";i:400;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}
_wp_attached_file
2018/02/Aw.Article-180221-Channel-one-31.jpg
@iamake interesting - I've never ran into this problem. I'm pretty sure the attached postmeta is ordered by the meta ID, and I always assumed that attached_file was before attachment_metadata.
I'll have to think of a good solution to this.
@iamake check out 50ec0ba at let me know if that works for you.
Thanks ! That looks good to me. Should solve all issues.
Are you pushing this to the 4.2.2 version ?
@iamake Yes, 4.2.2 includes the fix and has been published.
Perfect. Thank you !
https://github.com/ramsaylanier/WordExpressSchema/blob/567965748eae56589bf0521cc05b52c4e287dcc7/src/modules/Thumbnail/shapeThumbnail.js#L6-L7