I want to pass a variable with the block code like of JSON type in magento,
{{block type=\"multibanners/multibanners\" category_id=\"9\" name=\"multibanners\
I found this very useful and I thought I'd explain what I did in case it helps anyone else.
I have a few static blocks that I use to build some static pages with basic non-changing information (about-us type pages) which include some photos. The photos are very large (for a web page) and I wanted to use Magento's resizing facility. The only way I could work out to do this was to use the ideas here. I now have a block I can include on any cms static page/block when I want to have a resized image with several parameters. It's like a subroutine (am I allowed to say that?! ;o). Anyway, here's what I did.
The block:
{{block type="core/template" name="display_resized_img" gimg="IMG_0559.JPG" gsize="300" gpath="/wysiwyg/ShopFront/" gclass="about-us" galt="The shop" template="utilities/display_resized_img.phtml"}}
and the phtml code file:
getData('gimg');
$size = $this->getData('gsize');
$path = $this->getData('gpath');
$class = $this->getData('gclass');
$alt = $this->getData('galt');
$resizePath = Mage::getBaseDir ('media') . $path . "resized/" . $size . $img;
if (!file_exists($resizePath)):
$imagePath = Mage::getBaseDir('media') . $path . $img;
$imageObj = new Varien_Image($imagePath);
$imageObj->constrainOnly(TRUE);
$imageObj->keepAspectRatio(TRUE);
$imageObj->keepFrame(FALSE);
$imageObj->resize($size, null);
$imageObj->save($resizePath);
endif;
$resizeUrl = Mage::getBaseUrl ('media') . $path . "resized/" . $size . $img;
?>
Note I save my re-sized images in a resized folder and add the new size to the image filename so I can easily see what's happening and manage the files.
Thanks for reading!