Created
December 4, 2014 11:50
-
-
Save akool/097502b846a2f1d22578 to your computer and use it in GitHub Desktop.
Get the first image from content
This file contains hidden or 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 | |
| $content = $modx->resource->content; | |
| if(preg_match("/src=\"(.*?)\"/",$content,&$matches)){ | |
| $img = substr($matches[1],1,strlen($matches[1])); | |
| } | |
| else { | |
| $img = "assets/images/defaultImage.png"; | |
| } | |
| return $img; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment