ATTACH bbcode #77
Unanswered
DirtRIFWeb
asked this question in
Q&A
Replies: 1 comment
-
Hello! You can simply write a plugin thats convert any bbcode tag to what you need <script src="https://unpkg.com/@bbob/html/dist/index.min.js"></script>
<script src="https://unpkg.com/@bbob/preset-html5/dist/index.min.js"></script>
<script>
// you can prefetch this data
const imageIds = [94399]
function isAttachmentImage(id) {
return imageIds.indexOf(parseInt(id, 10)) >= 0
}
const myPreset = BbobPresetHTML5.extend(tags =>
Object.assign(tags, {
attach: (node, { render }) => {
const id = render(node.content)
if (isAttachmentImage(id)) {
return {
tag: 'img',
attrs: {
src: `/attachment.php?attachmentid=${id}`,
},
content: null,
}
}
return {
tag: 'a',
attrs: {
href: `/attachment.php?attachmentid=${id}`,
},
content: `File ${id}`,
}
},
}),
)
console.log(
BbobHtml.default('[b]Hello![/b] [ATTACH]94399[/ATTACH] [ATTACH]20200[/ATTACH]', myPreset()),
)
</script> Thats results into |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use vBulletin forum software and am integrating this for live previews, that will be it's only function I wont be saving any information.
One of the bbcodes within vBulletin is
[ATTACH]94399[/ATTACH]
which converts toattachment.php?attachmentid=94399
this can be either an image or a file.For the live preview aspect of this, how would I get this to convert attach codes to use an image or link?
Beta Was this translation helpful? Give feedback.
All reactions