Last active
December 22, 2015 04:19
-
-
Save sergiois/6416344 to your computer and use it in GitHub Desktop.
Función para coger y quitar la primera imagen del introtext de Joomla! (texto que va hasta el readmore)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// cogemos imagen de introtext | |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $this->item->introtext, $src); | |
$first_img = $src[1][0]; | |
if(!empty($src[1][0])){ | |
echo '<div class="first_img"><img src="'.$src[1][0].'" alt="" /></div>'; | |
} | |
// quitamos todas las imágenes de introtext | |
$re_cleanImages = '/<img[^>]*>/'; | |
$myCleanHtml = preg_replace($re_cleanImages,'',$this->item->introtext); | |
$myCleanHtml = str_replace('<p></p>','',$myCleanHtml); | |
echo $myCleanHtml; | |
// quitamos solo la primera imagen de introtext | |
$myCleanHtml = preg_replace("/<img[^>]+\>/i", '',$this->item->introtextl, 1); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment