Skip to content

Instantly share code, notes, and snippets.

@wasipo
Created September 12, 2018 17:16
Show Gist options
  • Save wasipo/2a04e6a11d6887e63793c5aa7e0bbaca to your computer and use it in GitHub Desktop.
Save wasipo/2a04e6a11d6887e63793c5aa7e0bbaca to your computer and use it in GitHub Desktop.
setumei
function getFirstImage($content) {
$pattern = "/<img.*?src\s*=\s*[\"|\'](.*?)[\"|\'].*?>/i";
preg_match($pattern,$content,$images);
if(empty($images)) {
$result = false;
} else {
$result = $images[0];
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment