Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.