New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tpl_getMediaFile() #2684
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I believe several places that use tpl_getMediaFile()
should be looked at as well, or they will simply inject false
into HTML. Also docs on the top of the function needs to be updated as well; it will not @return string
only now.
Some occurrences of tpl_getMediaFile()
:
https://github.com/splitbrain/dokuwiki/blob/cd7e1573e9ecf4c6d8d11dafcad2483b342be55a/feed.php#L62
Current usages in Dokuwiki, downloadable plugins and templates of this function: |
@geekitude will you update the PR with the changes requested by @phy25 ? |
Sorry, I was a bit overwhelmed by real life. Do you think that providing a default transparent image would be a good solution? I believe it would avoid empty/non-existing result all at once? |
Sound good! I would add a new parameter If you don't have the time to polish this I can go ahead and make the change (and still keep your credit) 😉 |
Thanks for your help. I'll give it a try soon and let you know if I need help 😉 |
Followed @phy25 idea to add a I don't know what to do with The Travis CI build failure :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! For the build failure you may need to rebase your commits. master
tests are fixed just recently.
If you need help I can rebase this for you...
I'm sorry but I don't know what 'rebase your commit' means, so, your help for that would be much appreciated :) |
Previously, if no candidate is found, the result would still always be last candidate url even if it doesn't exist (and function would trigger a Warning for trying to getimagesize() on a file that doesn't exist)
Here is a solution attempt, sorry for the long delay. According to my tests, absolute path isn't required
1b3e8f7
to
08a1326
Compare
@geekitude I rebased your branch locally, and force-pushed it to GitHub. Tests should be passing very soon :-) |
Kind of applied given suggestion but switched $fallback to boolean to reduce possible values.
@phy25 thanks again for your help, I hope the latest version with boolean $fallback works better :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. How to implement $fallback
(string or bool) is more of a design decision, but the current code is OK to merge.
Again, thanks for your contributions and patience!
Thanks for your help and patience! ✌️ |
These were introduced in #2684
Previously, if no candidate is found, the result would still always be last candidate url even if it doesn't exist (and function would trigger a Warning for trying to getimagesize() on a file that doesn't exist)