Last active
August 29, 2015 14:15
-
-
Save akinayturan/68c874069f72724f0293 to your computer and use it in GitHub Desktop.
WP ~ Eklentisiz Yazıdaki İlk Resmi Alma & Gösterme
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 | |
// Yazıdaki ilk resmi alma ve gösterme //datarar.com | |
function resimgoster() { | |
error_reporting(0); | |
global $post, $posts; | |
$resimbir = ''; | |
ob_start(); | |
ob_end_clean(); | |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
$resimbir = $matches [1] [0]; | |
if(empty($resimbir)){ //Eğer resim eklememişseniz | |
$resimbir = '//datarar.com/dr/tanitim/datarar-com-banner-149-149.jpg'; | |
} | |
return $resimbir; | |
} | |
function resimgoster_by_post($post) { | |
error_reporting(0); | |
$resimbir = ''; | |
ob_start(); | |
ob_end_clean(); | |
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
$resimbir = $matches [1] [0]; | |
if(empty($resimbir)){ //Eğer resim eklememişseniz | |
$resimbir = '//datarar.com/dr/tanitim/datarar-com-banner-149-149.jpg'; | |
} | |
return $resimbir; | |
} | |
?> |
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
<img src="<?php echo resimgoster(); ?>" alt="resim" width="200px" height="200px" /> |
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 echo resimgoster(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment