• I am developing a WordPress plugin for www.ads-software.com, it’s my very first plugin. There is a issue what I can’t fix myself (I did google a lot but still couldn’t find any solution). But maybe the solution of this problem is very simple for some of you. So please answer if you know a direct solution; I will be very grateful.

    My plugin allows user to make Tables with a Banner image for each column. Please check this demo link.

    For each column’s head section there are two parts. One is subject and another is image. And the shortcode is look like

    [head subject=”Standard” image=”https://shahriarblog.com/wp-content/uploads/2014/03/hello-5.jpg”%5D%5B/head%5D

    And the source code is like below for the above shortcode:

    function head($atts, $content = null) {
        extract( shortcode_atts( array(
            'color' => '#333',
            'banner' => 'visible',
            'subject' => 'Subject',
            'image' => 'https://shahriarblog.com/wp-content/uploads/2014/03/hello-5.jpg',
        ), $atts ) );
        return "<div class='gridacc'><h2 style='background:{$color}'>{$subject}</h2><div class='photo' style='display: {$banner}ne'><img src='{$image}' alt=''></div><dl>".do_shortcode($content)."</dl></div>";
    }
    add_shortcode ("head", "head");

    As you see the user has to know the url of the image to use them in shortcode. But instead of using image url I want to use just image name. For example I want to use image=”hello-5.jpg” instead of using image=”https://shahriarblog.com/wp-content/uploads/2014/03/hello-5.jpg&#8221;

    Another thing: Right now to get the url of an image, every user need to upload the image by WordPress Media and then from the Media Library they can get each image’s url. But is it possible to upload the image directly in my plugin folder instead of default WordPress Uploads folder?

    Here is a linkof a documentation of this plugin and source code if you are interested. Thanks a lot.

  • The topic ‘How to call an image by WordPress shortcode attribute?’ is closed to new replies.