FILE API - images problem

FILE API - images problem

by Lukas Celinak -
Number of replies: 3
Picture of Plugin developers

Hi,

im trying to upload HTML contetn to database and load it in other part of plugin (same like posts in glossary, or HTML BLOCK),

editor works fine, i can add or update contetn with images, but i have problem, when im trying to load images from variables in other parts of plugin.

This is variable, where i store content with images:

stdClass Object
(
    [id] => 11
    [orientation] => portrait
    [pagenumber] => 0
    [name] => test core
    [docbody] => <p><img src="https://moodle.org/pluginfile.php/114/mod_forum/post/1560888/blackboard-hi.png" alt="" width="600" height="411" /></p>
    [docbodyformat] => 1
    [docheader] => <p><img src="https://moodle.org/pluginfile.php/114/mod_forum/post/1560888/znakfr200x200.jpg" alt="" /></p>
    [docheaderformat] => 1
    [docfooter] => <p><img src="https://moodle.org/pluginfile.php/114/mod_forum/post/1560888/guide.png" alt="" width="156" height="130" /></p>
    [docfooterformat] => 1
    [description] => 
)
And this is my context

context_module Object
(
    [_id:protected] => 53603
    [_contextlevel:protected] => 70
    [_instanceid:protected] => 6171
    [_path:protected] => /1/848/12934/53603
    [_depth:protected] => 3
    [_locked:protected] => 0
)
im trying to acess content with loaded images trough internal plugin function, this is my testring code:

$description = file_rewrite_pluginfile_urls($object->docheader, 'pluginfile.php', 53603, 'mod_timetable', 'header', 11);

and this is stored file in file api:

259710 be3b708819110c87e0f847ddb18159c9f36a6a12 7bf20e74ff4443213932460d3bb8971b8c6d9191 53603 mod_timetable header 11 / znakfr200x200.jpg 2 629061 image/jpeg 0 znakfr200x200.jpg Administrator Čelinák allrightsreserved 1560168335 1560168373 0 NULL

Iin HTML_block it is same and everithing works fine, but i dont understand what im doing wrong.

This is link generated in $description variable:

<p><img src="http://xxx.xxx.sk/pluginfile.php/53603/mod_timetable/header/11/znakfr200x200.jpg" alt=""></p>

Thank you.

Attachment images.PNG
Average of ratings: -
In reply to Lukas Celinak

Re: FILE API - images problem

by Lorenzo Gaspari -
Hey Lukas,

i'm in the same situation, have you found a solution?

Many thanks
In reply to Lorenzo Gaspari

Re: FILE API - images problem

by Lukas Celinak -
Picture of Plugin developers
Yes i have solution, i had applied it and im using it in every plugin which i have, just write me to lukascelinak@gmail.com and i will help you when i will be in my office after holydays.
In reply to Lukas Celinak

Re: FILE API - images problem

by Lorenzo Gaspari -

Thanks Lukas, i just sent you an email.

Many thanks for your time.

Lorenzo