gdbbx_attachment

Developer Knowledge Level

This content is intended for WordPress developers, and it may require coding knowledge of WordPress, PHP, and JavaScript. Code examples provided here may contain errors or needs some additional coding. Make sure to test the code before using it on a live website!

This shortcode will display an image, video or audio type attachment based on the attachment file name or the ID.

Attributes

Shortcode has several attributes:

  • file: preferably, the attachment ID. If not, use the file name. This is required attribute!
  • style: additional CSS to add to the attachment style inline. Default: ”.
  • class: additional CSS class names to add to the rendered block. Default: ”.
  • target: value for the attachment link ‘target’ attribute. Default: ‘_blank’.
  • rel: value for the attachment link ‘rel’ attribute. Default: ”.
  • alt: value for the attachment link ‘alt’ attribute. Default: ”.
  • title: value for the attachment link ‘title’ attribute. Default: ”.
  • align: image alignment. Supports values: ‘alignnone’, ‘alignleft’, ‘alignrighy’, ‘aligncenter’. Default: ‘alignnone’.
  • width: width of the attached image. Default: ”.
  • height: height of the attached image. Default: ”.
  • autoplay: for video and audio attachment, enables autoplay. Default: false.
  • loop: for video and audio attachment, enables play in loop. Default: false.

Examples

Basic Use

[gdbbx_attachment file=1234]

Advanced Use

[gdbbx_attachment file="1234" rel="noopener" alt="My Image" align="aligncenter"]

        
0
0
361
Rate this reference

You are not allowed to rate this post.

Leave a Comment