fixed home simplenews picture match
This commit is contained in:
parent
83cbcefff9
commit
b5d76ec5e6
@ -43,12 +43,24 @@ if($vars['type'] == 'didactique'){
|
|||||||
|
|
||||||
// for HOME V2 : remove all table and other html, remains only the picture, from simplenews daily materio
|
// for HOME V2 : remove all table and other html, remains only the picture, from simplenews daily materio
|
||||||
if ($vars['type'] == 'simplenews' && $vars['view_mode'] == 'teaser') {
|
if ($vars['type'] == 'simplenews' && $vars['view_mode'] == 'teaser') {
|
||||||
|
// dsm($vars, "vars");
|
||||||
|
// dsm($vars['simplenews']->name);
|
||||||
// get the body field
|
// get the body field
|
||||||
$body = $vars['content']['body']['#items'][0]['value'];
|
$body = $vars['content']['body']['#items'][0]['value'];
|
||||||
// get the frist image only
|
// get the frist image only
|
||||||
preg_match('/<img[^src]+src="([^"]+)"[^>]+>/i', $body, $matches);
|
// preg_match_all('/<img[^src]+src="([^"]+)"[^>]+\/>/i', $body, $matches);
|
||||||
|
preg_match_all('/<img([\w\W]+?)\/>/i', $body, $imgs);
|
||||||
|
// dsm($imgs);
|
||||||
|
foreach ($imgs[1] as $key => $value) {
|
||||||
|
preg_match('/src="([^"]+)"/i', $value, $matches);
|
||||||
|
// dsm($matches[1]);
|
||||||
|
if (strpos('cale.jpg', $matches[1]) === false) {
|
||||||
// get the source path of the image
|
// get the source path of the image
|
||||||
$img_src = preg_replace('/^\/?sites\/default\/files\//', '', $matches[1]);
|
$img_src = preg_replace('/^\/?sites\/default\/files\//', '', $matches[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dsm($img_src);
|
||||||
// generate the uri of styled image
|
// generate the uri of styled image
|
||||||
$img_uri = image_style_url("card-full", $img_src);
|
$img_uri = image_style_url("card-full", $img_src);
|
||||||
// generate the styled image file
|
// generate the styled image file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user