mastah, gimana cara WP agar image nya menggunakan eksternal Host


Status
Not open for further replies.

dhyhost

Web Hosting Service
The Warrior
Verified Provider
itu berarti theme Tuan pakai timthumb jadi walaupun ambil gambar dari host luar tapi jadinya akan tersimpan di hosting..coba ganti theme lain

coba di cek di panel themesnya, biasanya bisa di disable timthumbnya
 

In.mY_M!ND

New Member
Kalo mau ubah code, bisa ambil contoh disini
PHP:
css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
Buat ganti timthumb, munculin image eksternal host di post thumbnail ;)
 

warsito

Poster 2.0
itu berarti theme Tuan pakai timthumb jadi walaupun ambil gambar dari host luar tapi jadinya akan tersimpan di hosting..coba ganti theme lain

yah tapi thema nya mahal Tuan, itu yg berbayar sayang kalu di buang gitu aja
Kalo mau ubah code, bisa ambil contoh disini
PHP:
css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
Buat ganti timthumb, munculin image eksternal host di post thumbnail ;)

oke Tuan saya coba dulu
 

warsito

Poster 2.0
Kalo mau ubah code, bisa ambil contoh disini
PHP:
css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/
Buat ganti timthumb, munculin image eksternal host di post thumbnail ;)
oya Tuan, ini kode nya di letak kan di mana, kan ada 2 kolom kode atas sama bawah. lalu masuk ke "functions.php" itu kode di sisip kan di sebelah mana ?
 

warsito

Poster 2.0
ya dipilih aja bro, mempertahankan theme mahal, atau hemat space. btw sampe habis berapa giga sih emangnya?
saya pakai vps, kalau hdd nya masih banyak, tapi "ram" nya boros, tagihan jadi naik terus, padahan traffic belum naik ,.. hehe :(
 

In.mY_M!ND

New Member
oya Tuan, ini kode nya di letak kan di mana, kan ada 2 kolom kode atas sama bawah. lalu masuk ke "functions.php" itu kode di sisip kan di sebelah mana ?
Kalo saya gini, kode kolom atas atau
PHP:
function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_img = $matches[1][0];

  if(empty($first_img)) {
    $first_img = "/path/to/default.png";
  }
  return $first_img;
}
di masukin di "functions.php"

Terus berhubung wp theme saya itu post thumbnail ada di "index.php" ma "archive.php", jadi saya cari tuh yang code kaya gini, misal:
PHP:
<?php if ( has_post_thumbnail() ) { ?>
the_post_thumbnail('featured',array('title' => ''.get_the_title().'','alt' => ''.get_the_title().''));
<?php } ?>

terus saya ubah tuh jadi gini:
PHP:
<?php if ( has_post_thumbnail() ) { ?>
the_post_thumbnail('featured',array('title' => ''.get_the_title().'','alt' => ''.get_the_title().''));
<?php } elseif (function_exists('catch_that_image')) { ?>
<img width="100px" height="100px" src="<?php echo catch_that_image (); ?>" class="attachment-featured">
<?php } ?>
Selama ini saya pake cara itu, buat ngehemat hdd,
tinggal posting image kaya biasa (tanpa featured image), otomatis dia nyari image yang ada di postingan dijadiin post thumbnail tanpa nyimpan di hosting

sorry kalo salah :peace::4:
 

warsito

Poster 2.0
Kalo saya gini, kode kolom atas atau
PHP:
function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_img = $matches[1][0];

  if(empty($first_img)) {
    $first_img = "/path/to/default.png";
  }
  return $first_img;
}
di masukin di "functions.php"

di masukin di "functions.php" di sebelah kode apa Tuan, ? apa di letakan di paling atas atau gimana ? maaf banyak tanya. saya kagak mudeng :)
 
Status
Not open for further replies.

Top