tristantbg / kirby-shopify

MIT License
61 stars 7 forks source link

img_url() method in README.md #17

Closed eqtrd closed 1 year ago

eqtrd commented 1 year ago

Hi Tristan !

It seems there is an error in your README.md.

Resizing images with <img src="<?= $page->shopifyImages()->toStructure()->first()->img_url('1000x1000') ?>" may not work.

it should probably be : <img src="<?= $page->shopifyImages()->toStructure()->first()->src()->img_url('1000x1000')?>" alt="">

img_url method requires a field object.

Thank you

tristantbg commented 1 year ago

Hi @eqtrd Are you sure ? Both should work with this : https://github.com/tristantbg/kirby-shopify/blob/master/index.php#L47

eqtrd commented 1 year ago

<img src="<?= $page->shopifyImages()->toStructure()->first()->img_url('1000x1000') ?> doesn't return anything for me (empty image src) while : <img src="<?= $page->shopifyImages()->toStructure()->first()->src()->img_url('1000x1000')?>" alt=""> returns the good url.

I guess $field in https://github.com/tristantbg/kirby-shopify/blob/master/index.php#L47 should be a fieldObject. and var_dump($page->shopifyImages()->toStructure()) returns a StructureObject.

tristantbg commented 1 year ago

Indeed... you are right !

Merci ;)