Author Topic: <tdbutton> image relative path doesn't work?  (Read 3242 times)

KanedNUnable

  • Newbie
  • *
  • Posts: 19
    • View Profile
<tdbutton> image relative path doesn't work?
« on: June 19, 2012, 02:48:46 AM »
Hi, this may be a bug (in which case it's directed at Corey) or may just be something I'm doing wrong (in which case directed at anyone who cares to correct me please!)...

I have a row of <tdbuttons> at the bottom of my main screen.  When I replaced the standard buttons with images, at first I used images stored in my My Pictures folder, so had to hard code the full path for the image file.  As I've gotten better at customising TD, I moved the images to the datastore.  When I changed the links and selected the images from the datastore, TD specified the path as relative - which is cool except it doesn't seem to work, none of the pictures seem to render...  When I change it to a hard coded path in the exact same location though, all works perfectly again.

Not a big issue, but just thought I'd raise it in case it was a bug and Corey wasn't aware - or perhaps it's something I'm doing wrong and someone can correct me.

Cheers!
Jamie

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5381
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #1 on: June 19, 2012, 09:48:30 AM »
Relative paths should work.  In fact, if you use the "Insert Token" button to insert your <tdbutton>, and use the "Browse..." button to select an image, it should insert the image using a relative path, IF the image you select is within your currently selected data store (otherwise it will insert an absolute path).  As a quick example, I used the "Insert Token" button and selected one of the chip images that comes with the software:

<tdButton type="NextRound" image="images\chip_black.gif">

Notice that the image path is relative, and it does indeed work in my layout.

Why don't you post the HTML you're using?

KanedNUnable

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #2 on: June 20, 2012, 08:27:42 AM »
Hi Corey,

That's exactly what I did at first (and have done again now to double check) - Insert Token, Browse, Select File, and it does indeed insert a relative path - but it doesn't render the image for me.  Whereas if I hard-code the full image, it does.  My chip images are definitely stored in a sub-folder of 'images' in my currently selected datastore (I only have one, the default).

So this is what TD inserts and doesn't work for me:

<tdButton type="AddPlayers" image="images\Buttons\PlayersAdd.png" link="true" tooltip="Add players to the tournament">

But if I hard code the path like this, it does:

<tdButton type="AddPlayers" image="C:\Users\Jamie\Documents\The Tournament Director 2\Data\images\Buttons\PlayersAdd.png" link="true" tooltip="Add players to the tournament">

My data store is definitely "C:\Users\Jamie\Documents\The Tournament Director 2\Data" - there are many other things I've customised within TD that have worked fine for me using relative paths and the data store, it's just tdbuttons that don't seem to work for me...

Cheers
Jamie

Magic_fubu

  • Hero Member
  • *****
  • Posts: 1035
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #3 on: June 20, 2012, 09:25:44 AM »
If I may ask, which version are you running? I seem to recall an earlier version where this was a bug, but I may be wrong.
My cowboys shot down your rockets
---
If you send a request to me please send that you got me from here w/your TD name to confirm. Thanks!

KanedNUnable

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #4 on: June 20, 2012, 04:10:14 PM »
I'm not at my home computer just now to check, but I only downloaded and installed the software a month or so ago so I'm fairly certain it's the latest version I've got...?

Cheers
Jamie

KanedNUnable

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #5 on: June 21, 2012, 07:37:12 AM »
It's v3.1.1

Cheers
Jamie

Magic_fubu

  • Hero Member
  • *****
  • Posts: 1035
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #6 on: June 21, 2012, 01:50:19 PM »
Same version as I'm currently running... Going to check my picture paths and see what I've got on my machine... Will update as an Edit to this post....

EDIT

Upon tinkering with the files, I too am unable to get the relative path to work. Works perfectly fine with hardwired path. Tried it with the <datastore> token and as just templates\image.png path, and neither would work...
« Last Edit: June 21, 2012, 01:55:32 PM by Magic_fubu »
My cowboys shot down your rockets
---
If you send a request to me please send that you got me from here w/your TD name to confirm. Thanks!

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5381
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #7 on: June 21, 2012, 03:02:08 PM »
Ugh, this looks like one of those rare places where running in development mode works differently than running in release mode.  It works for me in development mode.  I see the issue in release mode.  Makes it difficult to debug and fix.  I'll look into the issue.

Corey Cooper

  • Administrator
  • Hero Member
  • *****
  • Posts: 5381
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #8 on: June 21, 2012, 03:31:39 PM »
I think what the issue here is that the relative path gets modified by IE when in release mode.  We have the same issue when an image is simply inserted into the layout:

<img src="images\chip_orange.gif">

This works in my development environment, but suffers the same problem you guys are seeing when in release mode.  But this should work:

<img src="<datastore>\images\chip_orange.gif">

And (if I recall correctly) this is why I added the the <datastore> and <home> tokens.

Unfortunately, this won't work for a <tdbutton> because the <dataStore> token would be nested inside of the <tdbutton> token, and it would be encoded:

<tdButton type="NextRound" image="&lt;dataStore&gt;\images\chip_black.gif">

To fix this, I've added some special code in 3.2 to check the image attribute of the <tdbutton> token specifically to see if it starts with either <dataStore> or <home>, and replace it with an absolute path to the current data store.  I've updated the Insert Token dialog to prepend the image path with <dataStore> if the image is located in your data store.

Magic_fubu

  • Hero Member
  • *****
  • Posts: 1035
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #9 on: June 21, 2012, 09:11:59 PM »
Thanks for the update Corey!
My cowboys shot down your rockets
---
If you send a request to me please send that you got me from here w/your TD name to confirm. Thanks!

KanedNUnable

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: <tdbutton> image relative path doesn't work?
« Reply #10 on: June 22, 2012, 11:02:37 AM »
Cool thanks indeed for the update Corey ;D

It's not a major issue as it still works perfectly with hard-coded paths, and I only have 8 or so affected images - but thanks for the impending fix.

Got my new layout pretty much sorted (finally!) after days of tinkering - looking forward to seeing the lads' reaction tomorrow night when we play our second tourney  :D

All the best
Jamie