WordPress.org

Support

Support » Themes and Templates » CSS image paths and other MIME type issues

CSS image paths and other MIME type issues

  • I’ve been having some trouble with my links to javascript, css and image files with a theme i’m developing. My console shows me that my js, css and image files are being interpreted as MIME type text/html, which obviously means they aren’t working. I fixed the js and css links in my header by adding get_template_directory_uri() in the url, but I’m not sure how to fix my image paths in my CSS, as no matter what path I add, it seems not to work – absolute, relative, etc..

    I would love to know the reason why my paths aren’t working. Here is my header linkage code:

    <link type="text/css" rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
    	<link type="text/css" rel="stylesheet" href="style.css"  />
    
    	<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/klass.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    	<script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
    	<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/code.photoswipe.jquery-3.0.4.min.js"></script>
Viewing 2 replies - 1 through 2 (of 2 total)
  • In general, all references to files should be absolute in WP. The only exception is in a style sheet, where references are relative to the style sheet. You can usually get what you want in your HTML file using bloginfo() and the appropriate parameter concatenated to what remains of the path.

    Just use relative paths in ur() calls in style sheets.

    Cheers

    PAE

    Chip Bennett

    @chipbennett

    Theme Review Admin

    Why are you linking jQuery from an external library, when WordPress bundles/enqueues its own version? That will almost always cause issues/conflicts/unintended consequences.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CSS image paths and other MIME type issues’ is closed to new replies.