Created
January 8, 2018 13:07
-
-
Save rexxars/4d4ac669e378621a2c449093b681860b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once './vendor/autoload.php'; | |
$client = new Sanity\Client([ | |
'projectId' => '3do82whm', | |
'dataset' => 'production', | |
'useCdn' => true, | |
]); | |
$doc = $client->getDocument('47abbe60-f184-4eff-99e0-3a85c5c07c3a'); | |
$html = Sanity\BlockContent::toHtml($doc['body'], [ | |
'serializers' => [ | |
'image' => function ($node) use ($client) { | |
$image = $client->getDocument($node['attributes']['asset']['_ref']); | |
$url = $image['url'] . '?w=640'; | |
return '<img src="' . $url . '">'; | |
} | |
] | |
]); | |
echo $html; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment