• Resolved eyeofthenyte

    (@eyeofthenyte)


    I am trying to set a default image so I can pull it for a Discord Embed post. I have the webhook working but I can’t find where this url is stored anywhere. I’ve scoured the wp_posts and wp_postmeta tables and can’t find where it is even referenced. Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    Hello,

    The DFI uses the WordPress media library. And it only stores the attachment ID.
    Just as a regular featured image.
    A regular featured image is stored in post_meta _thumbnail_id per post.
    The DFI is an image stored in the wp_options > dfi_image_id

    In your use case I would download the image, and upload it to the media library.
    And save that ID as the dfi_image_id.

    I don’t know how technical you are but this snippet can download and insert in the media library.

    Let me know how it goes.

    Thread Starter eyeofthenyte

    (@eyeofthenyte)

    Ahh I see. I guess I’m more looking to generate a link for said image. I’ll give the snippet a try. I’m pretty new to all of this but I think that’s in the media.php file. Taking a stab in the dark haha. Thanks for your assistance so far.

    Plugin Author Jan-Willem

    (@janwoostendorp)

    What exactly are you trying to do?
    I might be able to point you more in a better direction.

    Thread Starter eyeofthenyte

    (@eyeofthenyte)

    I am trying to make a URL for either the DFI or the normal featured image. I know that I need to reference the the ID but am uncertain how to generate the rest of the URL. Place it into the $thumb_url variable below so it goes to my websocket appropriately.
    The best I achieved was getting a “default.jpg” at one point but it was essentially just a default missing image icon.

    
        if ( $new_status != 'publish' || $old_status == 'publish' || $post->post_type != 'post')
            return;
     
        $webhookURL = get_option('discord_webhook_url');
        $id = $post->ID;
    
        //$author = $post->post_author;
        //$authorName = get_the_author_meta('display_name', $author);
        $postTitle = $post->post_title;
        $permalink = get_permalink($id);
        $thumb_url = "default-or-featured-image-url";
        $description = $post->post_excerpt;
        $timestamp = $post->post_date;
    
        $postData = json_encode([
        "content" => "@here A dragonet just dropped off a new parchment: ",
        //"avatar_url" => "image url here",
        // Embeds Array
        "embeds" => [
            [
                "title" => $postTitle,
                "type" => "rich",
                "description" => $description,
                "url" => $permalink,
                "timestamp" => $timestamp,
                "color" => hexdec( "3366ff" ),
                "footer" => [
                    "text" => "EoN Creations  -  https://eoncreations.com",
                    "icon_url" => "https://eoncreations.com/wp-content/uploads/2020/02/cropped-EggOracle-180x180.png"
                ],
                "image" => [
                    "url" => $thumb_url
                ],
                "thumbnail" => [
                    "url" => $permalink
                ]
                ]
            ]   
        ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
    
    Plugin Author Jan-Willem

    (@janwoostendorp)

    I’m still not 100% clear on how your process goes, but I don’t think that’s needed at this point.

    To get the url based on an ID there is wp_get_attachment_url.
    Or maybe the WordPress rest API can help you can get pretty much all data using:
    example.com/wp-json/wp/v2/media/YOUR_ID

    Thread Starter eyeofthenyte

    (@eyeofthenyte)

    You were right. I was just messing up with the syntax and arguments within the wp_get_attachment_url. Thanks again! Appreciate your help and enjoy the plugin as well.

    Plugin Author Jan-Willem

    (@janwoostendorp)

    No problem.

    Good luck ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Database Value’ is closed to new replies.