Skip to content

Shortcodes

Daniel M. Hendricks edited this page Oct 26, 2018 · 4 revisions

[b2_object]

Returns a hyperlink of the specified object/file (or error string if bucket/file do not exist).

🚧 Currently, only files in public buckets are supported.

Parameters

  • bucket (string): The name of the B2 bucket (optional; defaults to selected bucket in plugin settings)
  • path (string): The relative path to the file within the bucket
  • silent (bool): Whether or not to output errors if bucket or path does not exist. Default: false
  • output (string): 'url', 'link' or 'image'. Defaults to 'image' when content is passed between the tags, else 'url'
  • title (string): The (optional) title tag when output is 'image'

Usage Examples

Return the URL of an Object:

[b2_object bucket="my-bucket-name" path="wp-content/uploads/2019/10/example.pdf"][/b2_object]

Result:

https://f001.backblazeb2.com/file/my-bucket-name/wp-content/uploads/2019/10/example.pdf

Return a Hyperlink Tag (nested shortcodes supported):

[b2_object output="link" bucket="some-bucket" path="wp-content/uploads/2019/10/example.pdf"]Click Here for the PDF[/b2_object]

Result:

<a href="https://f001.backblazeb2.com/file/some-bucket/wp-content/uploads/2019/10/example.pdf">Click Here for the PDF</a>

Return an Image Tag

[b2_object output="image" bucket="some-bucket" path="wp-content/uploads/2019/10/kiwi-fruit.png" title="Kiwi Fruit"]A Photo of a Kiwi[/b2_object]

Result:

<img src="https://f001.backblazeb2.com/file/some-bucket/wp-content/uploads/2019/10/kiwi-fruit.png" alt="A Photo of a Kiwi" title="Kiwi Fruit" />