XF 2.1 Loading image

Ozzy47

Well-known member
In my CSS I have this:

CSS:
#CaptchaDiv {
    font: bold 17px verdana, arial, sans-serif;
    font-style: italic;
    text-align: center;
    color: @xf-paletteNeutral3;
    background-color: @xf-paletteNeutral1;
    background-image: url('src/addons/OzzModz/Spaminator/images/captcha.jpg');
    padding: 4px;
    -moz-border-radius: 4px;
    -webkit-border-radius: 4px;
    border-radius: 4px;
}

In the folder, src/addons/OzzModz/Spaminator/images have the captcha.jpg loaded. All the folders are 755 and the image is 644 or 755.

If you try to load the image you get a 403 forbidden error. If I change the image to the styles folder, and change the CSS to background-image: url('styles/captcha.jpg'); the image loads. The styles folder is 755 and the image is 644. Not sure what the issue is why it will not load the image in the original location.
 
You likely have configured your web server to forbid requests from the src/ directory. If you are using nginx, the documentation for friendly URLs provides this configuration by default. Given that users of your add-on may have similar configurations, you shouldn't serve static files from your add-on directory. You should place them in a _files/ directory instead and customize the build process accordingly.


Hmm, okay, thanks for the tip, I'll have to change that around tomorrow.
 
The add-on directory is not supposed to be web accessible. If you want to ship images with your add-on, they'll have to go into the style directory. You can include them into the release package with the build.json automatically.
 
You likely have configured your web server to forbid requests from the src/ directory. If you are using nginx, the documentation for friendly URLs provides this configuration by default. Given that users of your add-on may have similar configurations, you shouldn't serve static files from your add-on directory. You should place them in a _files/ directory instead and customize the build process accordingly.
The add-on directory is not supposed to be web accessible. If you want to ship images with your add-on, they'll have to go into the style directory. You can include them into the release package with the build.json automatically.

Worked out perfect. Thank you both for your help. :)
 
Back
Top Bottom