• Resolved claudioliverano

    (@claudioliverano)


    Hello!
    Your plugin is saving me.. but I have one problem.

    1. Created a new content type (with another plugin)
    2. Enabled “Post To Telegram”
    3. Edited template message with custom fields
    4. Here the other settings:

    Excerpt Newlines OFF
    Single Messsage ON (After Text)
    Analysis Mode HTML STYLE
    Inline Button OFF
    Disable Preview Webpage OFF
    Disable Notification OFF

    The new content type has 5 custom fields (1 url field named “link”).
    I simply use “{cf:link}” code in the template. I can see the link in the telegram bot message but I can’t see the image preview. Any suggests?
    I tried 1 minute delay.
    I tried html prefix og.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Manzoor Wani

    (@manzoorwanijk)

    Hello,
    If Single Message option is enabled and Image Position is set to After text, then the link preview will always show the image.

    I would suggest to disable Single Message option.

    Thread Starter claudioliverano

    (@claudioliverano)

    I tried your way but nothing changes.
    The message shows link without preview.
    BUT! I understand that the preview is blocked only to the direct Amazon’s urls.
    If I insert a youtube link (or other site link), the preview show up.

    Maybe..
    I can try to “create” a preview replacing that with my own image.
    How I can insert an attached image?

    My customized content type let me create an image-upload field but when I public the post, the telegram bot show “Array” instead of attached image.

    OTHER (Off problem) Question: Does the plugin support the customized inline button url for telegram? In the setting I can just replace “View Post” text and not the url attached (this because I want redirect people in another site, not in my created post).

    and.. thanks for the quickly reply!

    Manzoor Wani

    (@manzoorwanijk)

    I’m not sure what you mean by

    How I can insert an attached image?

    Regarding inline button, yes it’s possible to customise it using custom code.

    Thread Starter claudioliverano

    (@claudioliverano)

    The question is much simpler than it seems. Can I send an image in a telegram message through a custom image-upload field?

    Example:
    {cf:title_field}
    {cf:decription_field}
    {cf:image}

    Where {cf:image} is a custom field with upload (image only) function.
    When I try to send it, Telegram bot doesn’t show attached image.
    I want it like a “cover image”.

    Regarding inline button, should I edit the plugin code? Can you tell me which file exactly?

    Manzoor Wani

    (@manzoorwanijk)

    To use a different image instead of featured image, you can use this code:

    /* WP Telegram - use custom image */
    add_filter(
    	'wptelegram_p2tg_post_data_featured_image_url_value',
    	function ( $image_url, $post ) {
    
    		// get the image URL from "image" meta key
    		$image_url = get_post_meta( $post->ID, 'image', true );
    
    		return $image_url;
    	},
    	10,
    	2
    );
    /* WP Telegram - use custom image */

    To customize the inline button, here is a sample:

    /* WPTelegram Modify default inline button */
    add_filter(
    	'wptelegram_p2tg_default_inline_button',
    	function ( $button, $post ) {
    
    		// set the URL of your choice
    		$button['url'] = urldecode( get_permalink( $post->ID ) );
    
    		$button['text'] = 'Read Online';
    
    		return $button;
    
    	},
    	10,
    	2
    );
    /* WPTelegram Modify default inline button */

    Note: You should NEVER edit the plugin code. You can add the above code to functions.php of your active/child theme.

    Thread Starter claudioliverano

    (@claudioliverano)

    Ok, thank you. Let me try. I’ll update you as soon as possible!

    Thread Starter claudioliverano

    (@claudioliverano)

    I think I did something wrong:

    Inserted the first code in function.php.
    Recreated custom field named “image” (Type field: upload).
    Inserted the code {cf:image} in the P2TG settings template.
    Tried to public a post.
    Telegram Bot shows “Array” where the image should be.

    What if I try to insert an HTML code in the P2TG template like <img src="{cf:image}" />, where {cf:image} is an url field?

    I apologize for my poor skill

    Thread Starter claudioliverano

    (@claudioliverano)

    Regarding inline button, I need to replace this:

    $button['url'] = urldecode( get_permalink( $post->ID ) );

    with this:

    $button['url'] = url from custom field (a textbox);

    But I’m trying several codes without a good response.
    Maybe the plugin that I’m using for creating custom post and fields is not good..

    Manzoor Wani

    (@manzoorwanijk)

    That’s the sample code, you need to figure out the rest based on your set-up and custom field configuration. The code for image is to replace sending of featured image, you don’t need to add anything to template

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Need a link preview’ is closed to new replies.