Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#17050 closed defect (bug) (fixed)

Built in Thickbox close image relative path error

Reported by: maorb Owned by:
Priority: normal Milestone: 3.2
Component: External Libraries Version: 3.1
Severity: normal Keywords:
Cc: Focuses:

Description

When using the built in Thickbox modal window on the frontned, the link to the close image is a relative path to - ../wp-includes/js/thickbox/tb-close.png

This making the icon not appear if user is on an inside page of the site, since the relative path is no longer correct.

The file contains this is wp-includes/js/thickbox/thickbox.js

Lines 8-13 are these:

if ( typeof tb_pathToImage != 'string' ) {
	var tb_pathToImage = "../wp-includes/js/thickbox/loadingAnimation.gif";
}
if ( typeof tb_closeImage != 'string' ) {
	var tb_closeImage = "../wp-includes/js/thickbox/tb-close.png";
}

When replaced with relative path to root and not to parent directory, it is working well and fixes this error --

if ( typeof tb_pathToImage != 'string' ) {
	var tb_pathToImage = "/wp-includes/js/thickbox/loadingAnimation.gif";
}
if ( typeof tb_closeImage != 'string' ) {
	var tb_closeImage = "/wp-includes/js/thickbox/tb-close.png";
}

Change History (9)

#1 @dd32
16 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

You cant use absolute paths (relative to root) because not all WordPress installs are rooted at /

The thickbox script contains paths designed for use within the admin area, If you want to use it on the front end you need to add something similar to the following to your head:

<script type="text/javascript">
//<![CDATA[
var tb_pathToImage = "<?php echo site_url('/wp-includes/js/thickbox/loadingAnimation.gif'); ?>";
var tb_closeImage = "<?php echo site_url('/wp-includes/js/thickbox/tb-close.png'); ?>";
//]]>
</script>

See #6453

#2 @dd32
16 years ago

  • Milestone → Future Release
  • Resolution duplicate
  • Status closed → reopened

However, Now that I've closed it, I'm wondering why this isn't being handled by passing the url through site_url() + inserting it through our translation functions. This would allow it to work seamlessly on both the front and back ends..

#3 @maorb
16 years ago

@dd32 Thanks and I agree with you.
Meanwhile, I will use your solution of adding the js vars to the head, it will be better than changing the core.

#4 @dd32
16 years ago

  • Milestone Future Release → 3.2

#5 @dd32
16 years ago

  • Resolution → fixed
  • Status reopened → closed

(In [17596]) Pass image URL's to thickbox via L10n in script-loader.php. Allows thickbox to be used on any page in the install without defining the image URL variables. Fixes #17050

#6 @nacin
16 years ago

  • Resolution fixed
  • Status closed → reopened

#7 @nacin
16 years ago

(In [17608]) Revert [17596] for now. props kawauso, see #17057, see #17050.

#8 @dd32
16 years ago

  • Resolution → fixed
  • Status reopened → closed

(In [17609]) Revert [17608] adding back [17596] and actually include the dummy function this time. See #17057 Fixes #17050

#9 @azaozz
16 years ago

Perhaps we should (finally) separate the default scripts and default stylesheets from script loader and remove all these dummy functions. Should have done that when introducing load-scripts.php and load-styles.php.

That would probably make life a bit easier for caching plugins too.

Of course we will still need 1-2 dummy functions in these files when using a function directly in the JS args like in this case but that seems quite easier to manage and could be triggered by checking whether ABSPATH is defined, etc.

Note: See TracTickets for help on using tickets.