Generate random image of a dog in your post Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

    Generate random image of a dog in your post

    avatar
    Guest
    Guest


    Generate random image of a dog in your post Empty Generate random image of a dog in your post

    Post by Guest September 7th 2023, 1:40 pm

    Title: Generate random image of a dog in your post
    Description: You will be able to click an image of a dog and generate a random image of a dog in your post (updates your unpublished post). This is a fun way to play around.
    Version: All versions.
    Preview:

    Generate random image of a dog in your post SgPbU


    1. Go to AP > Modules > Javascript codes management > Enable javascript and then create new javascript.

    Name script: Random dog image generator
    Placement: In the topics.

    Add this code:

    Code:
    function callImage() {
     
      // Random images generated thanks to free API: https://github.com/jigsawpieces/dog-api-images

        $.ajax({
            url: 'https://dog.ceo/api/breeds/image/random',
            type: 'GET',
            dataType: 'json',
            success: function(data) {

                $('#text_editor_textarea').sceditor("instance").insertText('\n[img]' + data.message + '[/img]');

            },
            error: function(error) {
                console.error('Error fetching JSON:', error);
            }
        });

    }

    $(document).ready(function() {

        $(function() {
            $('<img src="https://i.ibb.co/Wv5Jjb8/3316536-animal-cachorro-dog-dogs-icon-1.png" />').insertAfter('.sceditor-group:last').on("click", function() {
                callImage();
            });

        });

    });

    Save. Check how it works.


    Note: In AwesomeBB version, it works only for quick reply.




    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15161
    Reputation : 1696
    Language : English,Greek
    Location : Greece

    Generate random image of a dog in your post Empty Re: Generate random image of a dog in your post

    Post by skouliki September 7th 2023, 6:05 pm

    Hello @The Raven

    Is this code written by you ?


    Rules wrote:
    Rules you must stick to
    *Any codes posted must be your own codes and not a small change of codes / JavaScripts made by others on the support forum.

    avatar
    Guest
    Guest


    Generate random image of a dog in your post Empty Re: Generate random image of a dog in your post

    Post by Guest September 7th 2023, 6:16 pm

    Itvis made by me. I simply found ni key API and made a call, took data, used it in my own way and that's it.
    skouliki
    skouliki
    Manager
    Manager


    Female Posts : 15161
    Reputation : 1696
    Language : English,Greek
    Location : Greece

    Generate random image of a dog in your post Empty Re: Generate random image of a dog in your post

    Post by skouliki September 7th 2023, 6:30 pm

    somebody else has created that key did you get permission to use it ? do you know if it is copyrighted?

    sources
    https://codepen.io/louisnelza/pen/GGJoqY
    https://github.com/rsumitaj/dogs-api-Ajax/blob/master/script.js

    avatar
    Guest
    Guest


    Generate random image of a dog in your post Empty Re: Generate random image of a dog in your post

    Post by Guest September 7th 2023, 6:36 pm

    No. This is the OG of API, all code is there. https://github.com/jigsawpieces/dog-api-images
    This is the licence: https://github.com/jigsawpieces/dog-api-images/blob/main/LICENSE


    Commercial use
    Modification
    Distribution
    Patent use
    Private use

    GNU General Public License v3.0
    Permissions of this strong copyleft license are conditioned on making available complete source code of licensed works and modifications, which include larger works using a licensed work, under the same license. Copyright and license notices must be preserved. Contributors provide an express grant of patent rights.