رفتن به مطلب

قرار دادن آلت تصاویر به صورت خودکار


پست های پیشنهاد شده

سلام کد یا افزونه ای هست که به صورت خودکار آلت و توضیحات عکس رو با استفاده از تایتل پست پر کنه 

این قسمت ها منظورم هست داخل عکس کادر کشیدم

بیشتر بخش متن جایگزین اولویت داره چون برای افزونه یواست سئو مهمه 

ممنون

Screenshot (245).png

 0
لینک به ارسال

سلام

با افزونه زیر می تونید انجام بدید

https://wordpress.org/plugins/bulk-image-alt-text-with-yoast/

لینک به ارسال
در 17 ساعت قبل، SM-Mahdavi گفته است :

سلام

با افزونه زیر می تونید انجام بدید

https://wordpress.org/plugins/bulk-image-alt-text-with-yoast/

این افزونه رو تست کردم متاسفانه کار نمیکنه اصلا

این تنظیمات افزونه

Screenshot (249).png

ویرایش شده توسط فردین
لینک به ارسال
در 19 ساعت قبل، SM-Mahdavi گفته است :

سلام

با افزونه زیر می تونید انجام بدید

https://wordpress.org/plugins/bulk-image-alt-text-with-yoast/

اکثر افزونه ها مشکل دار هستند و نمیشه 

من چند تا کد پیدا کردم از سایت هایه خارجی منتها این ها اسمه خوده عکس رو قرار میدن برای مشخصات

چطور میشه تایتل پست رو قرار داد

/**
 * Auto Add Image Attributes From Image Filename 
 *
 * @author Arun Basil Lal
 * @refer https://millionclues.com/?p=3908
 * @plugin https://wordpress.org/plugins/auto-image-attributes-from-filename-with-bulk-updater/
 */
function abl_mc_auto_image_attributes( $post_ID ) {
  $attachment = get_post( $post_ID );
  
  $attachment_title = $attachment->post_title;
  $attachment_title = str_replace( '-', ' ', $attachment_title ); // Hyphen Removal
  $attachment_title = ucwords( $attachment_title ); // Capitalize First Word
  
  $uploaded_image = array();
  $uploaded_image['ID'] = $post_ID;
  $uploaded_image['post_title'] = $attachment_title; // Image Title
  $uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
  $uploaded_image['post_content'] = $attachment_title; // Image Description
  
  wp_update_post( $uploaded_image );
  update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
}
add_action( 'add_attachment', 'abl_mc_auto_image_attributes' );

https://millionclues.com/wordpress-tips/automatically-add-image-caption-description-and-alt-text-from-image-title/?unapproved=704336&moderation-hash=15ce91a4f0b2813f5f973b9fe359eb76&et_monarch_popup=true

 

add_action('added_post_meta', 'wpse_20151219_after_post_meta', 10, 4);

function wpse_20151219_after_post_meta($meta_id, $post_id, $meta_key, $meta_value) {

    // _wp_attachment_metadata added
    if($meta_key === '_wp_attachment_metadata') {

        // ----------------------------------------------------------------------
        // POST
        // ----------------------------------------------------------------------

        // Change basic fields on attachment post
        wp_update_post(array(
                           'ID'           => $post_id,
                           'post_title'   => "This is a TITLE for $post_id",
                           'post_content' => "This is the DESCRIPTION for $post_id",
                           'post_excerpt' => "This is the CAPTION for $post_id",
                       ));

        // ----------------------------------------------------------------------
        // POST META
        // ----------------------------------------------------------------------

        // Change ALT Text
        update_post_meta($post_id, '_wp_attachment_image_alt', "This is the ALT Text for $post_id");

        // Add Custom Field
        update_post_meta($post_id, '_wpse_20121219_my_custom_meta', 'MyCustomMetaValue');

        // ----------------------------------------------------------------------
        // POST META ( ATTACHMENT METADATA )
        // ----------------------------------------------------------------------

        // Change Image Metadata
        $meta_value[ 'image_meta' ] = array_merge($meta_value[ 'image_meta' ], array(
            'credit'    => 'https://black-buddha.com',
            'camera'    => 'The Best Camera EVER!',
            'copyright' => date('Y'),
            'title'     => "This is a META TITLE for $post_id",
            'caption'   => "This is a META CAPTION for $post_id",
        ));

        // Update The Image Metadata
        wp_update_attachment_metadata($post_id, $meta_value);

        // _wp_attached_file
        // _wp_attachment_metadata (serialized)
        // _wp_attachment_image_alt
        // _wpse_20121219_my_custom_meta

        $attachment_meta = get_post_meta($post_id);

        // width
        // height
        // file
        // sizes
        // image_meta
        //      aperture
        //      credit
        //      camera
        //      caption
        //      created_timestamp
        //      copyright
        //      focal_length
        //      iso
        //      shutter_speed
        //      title
        //      orientation
        //      title
        //      keywords

        $attachment_metadata = wp_get_attachment_metadata($post_id);
    }
}

https://wordpress.stackexchange.com/questions/125805/auto-add-image-title-caption-alt-text-description-while-uploading-images-in-word

 

/* 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(
// Specify the image (ID) to be updated
'ID' => $post_ID,
// Set image Title to sanitized title
'post_title' => $my_image_title,
// Set image Caption (Excerpt) to sanitized title
'post_excerpt' => $my_image_title,
// Set image Description (Content) to sanitized title
'post_content' => $my_image_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 );
}
}

https://wpkraken.io/blog/wordpress-images/

add_action('add_attachment', 'ehi_auto_populate_image_fields');
function ehi_auto_populate_image_fields($postID)
{
    if (wp_attachment_is_image($postID))
    {
        // Grab the Title auto-generated by WordPress
        $ehi_image_title = get_post($postID)->post_title;
 
        // Remove hyphens, underscores, and extra spaces
        $ehi_image_title = preg_replace('%\s*[-_\s]+\s*%', ' ',  $ehi_image_title);
 
        // Capitalize first letter of every word
        $ehi_image_title = ucwords(strtolower($ehi_image_title));
         
        $ehi_image_meta = array(
            'ID'        => $postID,
            'post_title'    => $ehi_image_title, // Image Title
            'post_excerpt'  => $ehi_image_title, // Image Caption (Excerpt)
            'post_content'  => $ehi_image_title, // Image Description (Content)
        );
 
        // Update the Alt Text
        update_post_meta($postID, '_wp_attachment_image_alt', $ehi_image_title);
 
        // Update the other fields
        wp_update_post($ehi_image_meta);
    } 
}

https://ehikioya.com/auto-populate-wordpress-image-alt-text/

اینها بودند بقیه سایتا هم همین کدارو گذاشتن چه تغییر باید داده بشه تو کد ها که پست تایتل تو فیلد ها نوشته بشه نه نام عکس 

ممنون 

لینک به ارسال

کد رو تست نکردم، ولی خب احتمالا باید جواب بده

 

function abl_mc_auto_image_attributes( $post_ID ) {
  $attachment = get_post( $post_ID );
  
  $attachment_title = get_the_title($attachment->post_parent);
  
  $uploaded_image = array();
  $uploaded_image['ID'] = $post_ID;
  $uploaded_image['post_title'] = $attachment_title; // Image Title
  $uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
  $uploaded_image['post_content'] = $attachment_title; // Image Description
  
  wp_update_post( $uploaded_image );
  update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
}
add_action( 'add_attachment', 'abl_mc_auto_image_attributes' );

 

لینک به ارسال
در 43 دقیقه قبل، Parsa گفته است :

کد رو تست نکردم، ولی خب احتمالا باید جواب بده

 


function abl_mc_auto_image_attributes( $post_ID ) {
  $attachment = get_post( $post_ID );
  
  $attachment_title = get_the_title($attachment->post_parent);
  
  $uploaded_image = array();
  $uploaded_image['ID'] = $post_ID;
  $uploaded_image['post_title'] = $attachment_title; // Image Title
  $uploaded_image['post_excerpt'] = $attachment_title; // Image Caption
  $uploaded_image['post_content'] = $attachment_title; // Image Description
  
  wp_update_post( $uploaded_image );
  update_post_meta( $post_ID, '_wp_attachment_image_alt', $attachment_title ); // Image Alt Text
}
add_action( 'add_attachment', 'abl_mc_auto_image_attributes' );

 

ممنون استاد همین کد رو میخاستم عمل کرد ممنون

یک سوال دیگه

 اگر بخوایم تو بخش توضیح مختصر و توضیح از تگ ها و محتوای متن استفاده کنیم یا زمینه ی دلخواه چطور باید تنظیم کنیم ایا میشه اصلا ؟

مثلا بخش توضیحات مختصر محتوای متن باشه و توضیحات برچسب ها یا زمینه ی دلخواه و .. 

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...