MODX
0
Вклад в тег
<?php
// Вызов [[thumbon_for_content? &content=`[[*content]]`]]
preg_match_all(
'/<img[^>]+src="?\'?([^"\']+)"?\'?[^>]*>/i',
$content,
$matches
);
if (!empty($matches[0]))
{
foreach ($matches[0] as $key => $tag) {
$link = preg_match_all('/<img[^>]+src="?\'?([^"\']+)"?\'?[^>]*>/i', $tag, $matches2, PREG_SET_ORDER);
$new_link = $modx->runSnippet('phpthumbon', array('input' => $matches2[0][1], 'options' => 'w=200&h=200&fltr[]=wmi|/watermark.png|C|100'));
$new_tag = preg_replace('/src=\"(.*?)\"/',"src='$new_link'", $tag);
$content = str_replace($tag, $new_tag, $content);
}
}
echo $content;