Support » Fixing WordPress » Difficulty including image directory for widget plugin

  • Resolved Sarah_Frantz


    Forgive me if I’ve posted this question to the wrong forum.

    I want to use a graphic with my widget, but I’m having difficulty including the directory that contains the images specific to the plugin. If someone could point me in the right direction that would be great! The path I want to get to to make the images in the plugin’s stylesheet work is:

    my_plugin > assets > images

    So far if I absolutely link to the path of the images they work, but this doesn’t help me when I want to package this widget for other installations of WordPress.

    Thank you in advance!

Viewing 4 replies - 1 through 4 (of 4 total)
  • This will depend on if you’re looking at retrieve it by its file level path or its URL.

    I typically use the following:

    plugins_url( 'widget-name/assets/images/admin.png' )

    Try that – if it doesn’t work, let me know!

    Hey Tom!

    I’m thinking more so by its file level path. Let me explain a little bit more in-depth the widget I’ve created and perhaps that might help make sense of which route to take..

    The widget is VERY simple. It is just a textarea where the user can enter in information. The box that is built in the sidebar houses a div with a background image. I’m referencing a stylesheet within the widget plugin to retrieve the styles for this div – however the background images only work if I use the exact path to their location (i.e. the full website url) … I basically want to make this all “relative” so that I can recycle this plugin on other sites I have, so using the absolute path to the image wont work.

    I’m sure this is more of a file path/structure issue or even a css thing more than anything..

    Have I confused you?

    OH I’m dumb. haha you’re right. Sorry. Thank you!

    Guess I need more coffee…

    Don’t we all? 😉

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Difficulty including image directory for widget plugin’ is closed to new replies.