Hardcode image block with that includes on-state image

Permalink
Hi guys, Just like the title says
Id like to hardcode an image block with an on-state image included for hover over effect (standard for imageblock)
How can this be done?

xb385
 
jero replied on at Permalink Reply
jero
Try this:

$image = BlockType::getByHandle('image');
$image->controller->fID=1; // file id of image
$image->controller->fOnstateID=2; //file id of mouseover image
$image->controller->maxWidth=600;
$image->controller->maxHeight=800;
$image->controller->externalLink='http://example.com';
# Comment above and uncomment below for internal link
#$image->controller->internalLinkCID=1; // cID of page to link to 
$image->controller->forceImageToMatchDimensions=1; // 0 for no resize
$image->controller->altText='Some Text';
$image->render('view');

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.