How Can I Get The Url Of Featured Image From Rainlab Blog Plugin?
I need to know the url of a featured image attached in a blog post with Rainlab blog plugin in October CMS.
The image is saved in a directory something like ".../storage/app/uploads/public/59f/112"
I need to know it in the moment that I save the post because I want to get the url to save it in another table that it can access from another php file or system ( in Android App for example ), but I can't do it.
I try with (in FormController.php) find the post:
$modelP = Post::find($this->controller->vars['formModel']['id']); $featuredImage = $modelP->featured_image->getPath();
But doesn't work, I get the blog object but it says that featured_image is not a variable.
In the table system_file only I can get the name of the file (disk_name) but not the entire url and I don't know in what directory it is saved.
Can anyone help me?
If you are using rain lab plugin then we do have some solution
first its featured_images not featured_image
It will going to return you a collection of images so if you need first image of it, then you replace code like
$modelP = Post::find($this->controller->vars['formModel']['id']); $featuredImage = $modelP->featured_images->first()->getPath();
$featuredImage this is full path of image
any other confusion please comment, happy coding :)
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?