Ads.id Lelang Coming Soon
  1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

Featured [SHARE] Auto Image Alt & Generate Image Alt yang udah diupload

Discussion in 'Blog/CMS Stuff' started by hujangede, Aug 13, 2017.



Ads.id Lelang Coming Soon
Tags:
  1. hujangede

    hujangede Super Hero

    Joined:
    Jul 12, 2011
    Messages:
    860
    Likes Received:
    60
    Location:
    Luar Angkasa
    Assalamualaikum...
    kali ini saya mau share Auto Image Alt & Generate Image Alt yang udah diupload.

    Image alt ini menurut saya penting sekali untuk seo image karena lebih cepat di index, seperti nya berbeda dengan yang tidak pake image alt...

    Sedikit cerita ane punya web wallpaper dan setelah diselidiki image nya belum ada image alt nya, kalo edit satu-satu bisa-bisa keriting tak berbentuk jari ane soalnya gambar nya puluhan ribu :( ...
    setelah ane cari cari informasi di dunia mbah google dapat lah yang work
    Trik cara auto image alt untuk gambar yang baru diupload
    dan
    Generate Image Alt yang udah diupload sebelum nya.

    1. Auto Image Alt untuk gambar yang baru upload
    kalo ini tinggal tambahkan kode di bawah functions.php
    Code:
    /* Automatically set the image Title, Alt-Text, Caption & Description upon upload
    --------------------------------------------------------------------------------------*/
    add_action( 'add_attachment', 'my_set_image_meta_upon_image_upload' );
    function my_set_image_meta_upon_image_upload( $post_ID ) {
    
        // Check if uploaded file is an image, else do nothing
    
        if ( wp_attachment_is_image( $post_ID ) ) {
    
            $my_image_title = get_post( $post_ID )->post_title;
    
            // Sanitize the title:  remove hyphens, underscores & extra spaces:
            $my_image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ',  $my_image_title );
    
            // Sanitize the title:  capitalize first letter of every word (other letters lower case):
            $my_image_title = ucwords( strtolower( $my_image_title ) );
    
            // Create an array with the image meta (Title, Caption, Description) to be updated
            // Note:  comment out the Excerpt/Caption or Content/Description lines if not needed
            $my_image_meta = array(
                'ID'        => $post_ID,            // Specify the image (ID) to be updated
                'post_title'    => $my_image_title,        // Set image Title to sanitized title
                'post_excerpt'    => $my_image_title,        // Set image Caption (Excerpt) to sanitized title
                'post_content'    => $my_image_title,        // Set image Description (Content) to sanitized title
            );
    
            // Set the image Alt-Text
            update_post_meta( $post_ID, '_wp_attachment_image_alt', $my_image_title );
    
            // Set the image meta (e.g. Title, Excerpt, Content)
            wp_update_post( $my_image_meta );
    
        }
    }
    sebelum ditambahkan, boleh di backup dulu web nya kalo masih ragu" . tapi ane berhasil kok..
    setelah disave terus coba upload gambar lalu liat apakah sudah otomatis alt image nya kalo udah ya selamat ente berhasil .......

    2. Generate Image Alt yang udah diupload sebelum nya.

    Untuk kali ini saya mengunakan plugin wordpres
    Auto Image Attributes From Filename With Bulk Updater
    Code:
    https://wordpress.org/plugins/auto-image-attributes-from-filename-with-bulk-updater/#description
    tinggal instal aja->save, terus tinggal masuk ke Setting>>Image Atribut>>Run Bulk updater.. udah deh tinggal ditungguin otomatis generate image alt.

    [​IMG]


    ilmu nya ane dapet di >
    Code:
    http://millionclues.com/wordpress-tips/automatically-add-image-caption-description-and-alt-text-from-image-title/
    Terimakasih...semoga bermanfaat..
     
  2. teazos

    teazos AdSense Fan

    Joined:
    Oct 11, 2015
    Messages:
    171
    Likes Received:
    15
    Makasih gan, sangat bermanfaat..
    Ijin prakek dl...

    Thanks
     
  3. onuzynaigy

    onuzynaigy AdSense Starter

    Joined:
    Apr 15, 2017
    Messages:
    56
    Likes Received:
    1
    Top gan

    Sent from my ASUS_Z008D using Tapatalk
     
  4. sayunjialie

    sayunjialie AdSense Fan

    Joined:
    Mar 9, 2017
    Messages:
    148
    Likes Received:
    6
    Wah penting nih.. ijin bukmak dl hu..
     
  5. Hafi Annasai

    Hafi Annasai AdSense Starter

    Joined:
    Jun 14, 2017
    Messages:
    52
    Likes Received:
    8
    Location:
    urang banjar
    Sharenya gurih sekali.
    Trims komendan.
     
  6. tripleamex

    tripleamex Hero

    Joined:
    Aug 8, 2015
    Messages:
    575
    Likes Received:
    16
    Location:
    Medan
    Like penceted

    Sent from my Redmi 4 using Tapatalk
     
  7. nurjaya

    nurjaya bit.do/rdpwindows

    Joined:
    Jan 13, 2010
    Messages:
    300
    Likes Received:
    10
    pertamax turbo gan + like
     
  8. andreas99

    andreas99 AdSense Fan

    Joined:
    Mar 23, 2015
    Messages:
    127
    Likes Received:
    7
    Location:
    Banyuwangi
    Thx infonya hu..
    btw apa bedanya tinggal instal plugin SEO FRIENDLY IMAGES hu? kan lebih simpel gitu klo plugin gak usah add2 code gitu di function.php
     
  9. mr.zulasri

    mr.zulasri New Comer

    Joined:
    Sep 14, 2015
    Messages:
    49
    Likes Received:
    1
    Jos gan,, suka suka suka
    tks

    Sent from my 2014817 using Tapatalk
     
  10. hujangede

    hujangede Super Hero

    Joined:
    Jul 12, 2011
    Messages:
    860
    Likes Received:
    60
    Location:
    Luar Angkasa
    beda nya, kalo pake plugin itu buat nambahin alt image ke semua gambar yang udah diupload

    kalo edit function.php itu buat upload image baru langsung otomatis alt, kalo misal kan hanya pakai plugin aja, berarti tiap upload gambar baru alt image nya tidak terisi secara otomatis, berarti harus di update lagi diplugin.

    kalo ane sih pake dua dua nya..

    biasanya sih yang main wallpaper yang bisa bulk posting gambar, rata-rata alt image nya kosong..seperti yang ane
     
  11. ibalmarwan

    ibalmarwan AdSense Starter

    Joined:
    Aug 2, 2014
    Messages:
    66
    Likes Received:
    2
    Location:
    Banda Aceh
    Terima kasih

    Sent from my C6603 using Tapatalk
     
  12. doorman

    doorman AdSense Fan

    Joined:
    Oct 28, 2016
    Messages:
    128
    Likes Received:
    9
    ini fungsinya bt apa ya mas bro ???
     
  13. hujangede

    hujangede Super Hero

    Joined:
    Jul 12, 2011
    Messages:
    860
    Likes Received:
    60
    Location:
    Luar Angkasa
    buat auto image alt gan, jadi masukin gambar gak perlu cape untuk copas judul nya ke alt nya, tapi langsung otomatis nge-generate
     
  14. ragiela

    ragiela AdSense Pro

    Joined:
    Apr 5, 2012
    Messages:
    433
    Likes Received:
    13
    Location:
    Di Hati Kici
    kalo yg no 1 yg script functions.php nanti image altnya otomatis keisi sama judul post ya gan ? terus kalo imagenya banyak dalam 1 post berarti isi image altnya sama semua atau gimana ?
     
  15. hujangede

    hujangede Super Hero

    Joined:
    Jul 12, 2011
    Messages:
    860
    Likes Received:
    60
    Location:
    Luar Angkasa
    iyah gan keisi otomatis tiap upload gambar baru

    image alt otomatis keisi sesuai judul image yang diupload nya gan, kalo judul nya beda-beda ya pasti alt nya pun sesuai nama image nya tersebut
     
  16. me.i.yam

    me.i.yam Hero

    Joined:
    Jan 26, 2015
    Messages:
    647
    Likes Received:
    79
  17. aji.satrio

    aji.satrio New Comer

    Joined:
    Aug 11, 2017
    Messages:
    20
    Likes Received:
    0
    Thaanks Gan ... saya praktekan dulu . like :komunis:
     
  18. mjrasta

    mjrasta AdSense Fan

    Joined:
    May 26, 2011
    Messages:
    117
    Likes Received:
    0
    Mau tanya, kalau image tidak di simpan di wordpress tapi di simpan di host lain jadi saya hanya ambil url nya, apakah bisa menggunakan plugin Auto Image Attributes From Filename With Bulk Updater? mohon petunjukknya...
     
  19. hujangede

    hujangede Super Hero

    Joined:
    Jul 12, 2011
    Messages:
    860
    Likes Received:
    60
    Location:
    Luar Angkasa
    Engga bisa kayak nya kalo dari host lain, kalo penasaran test aya gan soalnya ane blom pernah kalo host lain hehe
     
  20. mjrasta

    mjrasta AdSense Fan

    Joined:
    May 26, 2011
    Messages:
    117
    Likes Received:
    0
    Oke bang emang perlu di coba hehe...

    Sent from my AO5510 using Tapatalk
     

Ads.id Lelang Coming Soon


Ads.id Lelang Coming Soon

Share This Page