big update for home v2

This commit is contained in:
Bachir Soussi Chiadmi
2015-06-03 17:02:24 +02:00
parent 49004d7fee
commit 3ffbc09c10
26 changed files with 4210 additions and 1461 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php
// dsm($vars);
$node = $vars['node'];
@@ -40,4 +40,21 @@ if($vars['type'] == 'didactique'){
if(!empty($node->field_emvideo))
$vars['classes_array'][] = "emvideo";
}
// 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') {
// get the body field
$body = $vars['content']['body']['#items'][0]['value'];
// get the frist image only
preg_match('/<img[^src]+src="([^"]+)"[^>]+>/i', $body, $matches);
// get the source path of the image
$img_src = preg_replace('/^\/?sites\/default\/files\//', '', $matches[1]);
// generate the uri of styled image
$img_uri = image_style_url("card-full", $img_src);
// generate the styled image file
image_style_create_derivative("card-full", $img_src, $img_uri);
// theme the new image tag
$img = theme('image', array('path'=>$img_uri));
// replace the body with this new styled image
$vars['content']['body'][0]['#markup'] = $img;
}