We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

help with path OW::getPluginManager() | Forum

Ken Oct 22 '20
someone help how come I use this 

$thumb = OW::getPluginManager()->getPlugin( 'pluginkey' )->getUserFilesDir() . $item->id . '.jpg';

it works because it the right path but doesn't work to display image because it display the whole host path  /home/host/public_html/ow_userfiles/plugins/pluginkey/86.jpg

instead I need it to be like this


what am I doing wrong

The Forum post is edited by Ken Oct 22 '20
Marcus Oct 22 '20
change home path in config.php or simply use str_replace or preg_replace
The Forum post is edited by Marcus Oct 22 '20
Patricia Zorrilla Leader
Patricia Zorrilla Oct 22 '20

You are not confusing the URL with the PATH?

$url = 'ow_userfiles' .DS. 'plugins' .DS. 'miplugin' .DS. $itemId . ".jpg";

$path = OW::getPluginManager()->getPlugin(''miplugin')->getUserFilesDir() . $itemId . ".jpg";

Ken Oct 22 '20
Tried them doesn’t work 
why this code worked with path not url any other suggestions 
The Forum post is edited by Ken Oct 22 '20
Dev Forward
Dev Forward Oct 22 '20
I believe what you are looking for is getUserFilesUrl:

$thumb = OW::getPluginManager()->getPlugin( 'pluginkey' )->getUserFilesUrl() . $item->id . '.jpg';

Ken Oct 22 '20
ok thanks Patricia so much I got it to work using this

  $item->hasImage = OW::getPluginManager()->getPlugin( 'pluginkey' )->getUserFilesDir() . $item->id . '.jpg';

    if (file_exists($item->hasImage)) {        $thumb = 'ow_userfiles' .DS. 'plugins' .DS. 'pluginkey' .DS. $item->id . ".jpg";    } else {        $thumb = OW::getPluginManager()->getPlugin( 'pluginkey' )->getStaticUrl() . 'images/default.png';    }

Ken Oct 24 '20
Thanks too dev forward yours actually is way better across the site the one that I found worked Works on certain pages not all thanks A lot dev forward