Actually I saved my image generated by my plugin in a folder images_uploads
under my plugin folder
when I wrote my plugin where i need to include a relative path. I realise that there is error generated by Firebug. And the file actually point to wp-admin
. For example:
<img src = "./images-uploads/image.jpg">
Actually is <img src = "http://example.com/wp-admin/images_uploads/image.jpg">
what I want is <img src="http://example.com/wp-content/plugins/my-plugin/images-uploads/image.jpg">
Can anyone explain why the path is not from the current location of my plugin but instead the loaction of wp-admin. Is there any reference or documentation available???
I use the following in the main plugin file to define its URL and Path:
$this->plugin_url = plugins_url( '/', __FILE__ );
$this->plugin_path = plugin_dir_path( __FILE__ );
Then, print the image like:
echo '<img src = "' . $this->plugin_url . 'images-uploads/image.jpg">';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.