Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 4    Views: 58

ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
03/09/14 09:21 AM (10 years ago)

Use images in Control Panel custom sections?

Working on a new plugin and I'd like to use some images in the custom control panel sections to help explain the functions. I can make this work if I hardcode the entire URL path to the image in there, but that won't be good for repackaging/distributing the plugin. This used to work with index.php files if you referenced it like this: <img src="distance.png" /> It would just look in the current directory for images. I'm guessing this path is built some where else in the code in an include and I just need the proper reference. I've tried a couple of these variations with no luck… <img src="distance.png" > <img src="./distance.png" /> <img src="../distance.png" /> <img src="../../distance.jpg" /> Seems like HTML 101 but I'm stumped…..?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/09/14 03:01 PM (10 years ago)
I've included a couple of images in my control panel sections… In your plugin 'html' code, place your html image code using a 'similar' reference: <img src="../../files/plugins/SW_locationmenu/slmc_km.png"> and place the image in the ROOT of your plugin directory. That 'should' be it. Cheers! -- Smug
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
03/10/14 07:00 AM (10 years ago)
Thank you sir, that works- I was hoping to not have to hardcode the directory into the code and be able to reference the images in the same folder like we used to. Only because down the road if I duplicate this (or other) plugins that breaks the links to them. I guess this is one of those small changes that moving away from php in the control panel brings up. It's nice to be able to use images to explain features in the control panel, makes the plugin look a little more professional.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/11/14 02:18 AM (10 years ago)
Oh right; I see what you're saying… Well, I haven't looked into it, but I'm sure there must be some kind of javascript that can obtain the 'current directory'. If that could be worked into the code it should be doable. https://suite101.com/a/how-to-get-url-parts-in-javascript-a48335 Cheers! -- Smug
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
03/11/14 07:17 AM (10 years ago)
for sure, plenty of ways to to build that path- I just want to stay "BT Complaint" so that the control panel screens work with future updates to the BT Server and the plugin. I'm still cleaning up stuff from custom php I used in CP screens that don't work anymore after BT made the transition from .php to .html files. Lesson learned - don't over customize Davids code unless you plan to revisit it. I'm going with your suggestion for now so I can get this thing packaged in in the hands of some testers. Thanks for the assistance!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.