[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_format_nivo_attachment() – Format the Nivo output for attached images

Description

Format the Nivo output for attached images

Extract from Nivo's documentation

  • To add a caption to an image you simply need to add a title attribute to the image.
  • To add an HTML Caption simply set the title attribute to the ID of a element that contains your caption (prefixed with a hash).
  • Note that the HTML element that contains your caption must have the CSS class nivo-html-caption applied and must be outside of the slider div.
The HTML caption logic was implemented in version 1.12, using oik's format= parameter. Since there can be multiple sliders on a page the unique ID in the title attribute needs to take into account the slider instance (slider-id). The hyphen between the slider-id and post id helps ensure uniqueness. Added support for link=full, in addition to link=file. link=full will open the link to the original image link=file opens the links to the image of the selected thumbnail size

Usage

bw_format_nivo_attachment( $post, $atts );

Parameters

$post
( post ) required – the post to be displayed
$atts
( array ) required – array of parameters; name value pairs

Returns

void

TO DO

Add support for other file sizes if deemed really necessary.

Source

File name: oik-nivo-slider/nivo.php
Lines:
1 to 34 of 34
function bw_format_nivo_attachment( $post, $atts ) {
  $alt = null;
  if ( bw_validate_torf( $atts['caption'] ) ) {
    $title = get_the_title( $post->ID );
    if ( $format = bw_array_get( $atts, "format", false ) ) {
      $alt =  $title;
      $title = "#" . $atts['slider-id'] . "-" . $post->ID;
    } else {
    }
  } else {
    $title = null;
  }   
  $image = bw_get_attached_file_name( $post->ID, $atts );
  bw_trace2( $image, "image", true, BW_TRACE_DEBUG );
  if ( $image ) {
    $thumbnail = retimage( null, $image , $title, null, null, kv("data-thumb", $image) );
    if ( $atts['count'] ) {
      $thumbnail = str_replace( "/>", ' style="display:none" />', $thumbnail );
    }
    if ( bw_validate_torf( $atts['link'] ) ) {
      $permalink = bw_get_image_link( $post->ID );
      BW_::alink( "iframe", $permalink , $thumbnail, null );  
    } elseif ( $atts['link'] == "file" ) {
      BW_::alink( null, $image, $thumbnail, null, null, kv( "rel", $atts["slider-id"] )); 
    } elseif ( $atts['link'] == "full" ) {
      $full_image = bw_get_attached_file_name( $post->ID, array( "thumbnail" => "full" ) );
      BW_::alink( null, $full_image, $thumbnail, null, null, kv( "rel", $atts["slider-id"] )); 
    } else { 
      e( $thumbnail );
    }    
  } else {
    bw_trace2();
  } 
}
 
 View on GitHub View on Trac

Called by

1 to 1 of 1
  • Tests_nivo_php::test_bw_format_nivo_attachment() – We need to test the different values for "link" and ensure that "count" and "slider-id" are also set appropriately to avoid warnings.

Invoked by

    Calls

    1 to 9 of 9
    • alink() – Create a link
    • BW_::alink() – Outputs a link
    • bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set
    • bw_get_attached_file_name() – Return the ‘correct’ URL for the attached image
    • bw_get_image_link() – Return the URL that this image links to
    • bw_trace2() – Trace $value to the trace log file if tracing is active
    • bw_validate_torf() – Validate as true or false
    • kv() – Create a keyword value pair
    • retimage() – Return an image tag

    Call hooks

    Function name: bw_format_nivo_attachment
    Plugin ref: oik-nivo-slider – jQuery nivo slider
    Version: 1.17.0
    Sourcefile: nivo.php
    File ref: nivo.php
    Deprecated?: No
    API Letters: A,B,F,N

    Published: March 5, 2013 | Last updated: December 18, 2017

    Information

    Function name: bw_format_nivo_attachment
    Plugin ref: oik-nivo-slider – jQuery nivo slider
    Version: 1.17.0
    Sourcefile: nivo.php
    File ref: nivo.php
    Deprecated?: No
    API Letters: A,B,F,N

    Recent plugin updates

    oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
    SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
    oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
    oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
    oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

    Plugins

    • All Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins

    Themes

    • FREE themes
    • Bespoke themes
    • Premium themes

    Blocks

    • All Blocks
    • Block examples
    • About Blocks

    Shortcodes

    • All Shortcodes
    • Shortcode examples
    • About Shortcodes

    Reference

    • About APIs
    • All APIs
    • All Classes
    • All Files
    • All Hooks

    Support

    • Contact
    • Cookies policy
    • Get API key
    • Privacy
    • Request support
    • Sitemap
    • Stay informed
    • Terms and Conditions
    oik-plugins
    Email: oikplug@oik-plugins.com

    Weight shipping plugins

    Find out which cart weight shipping plugin you need for your WooCommerce site.
    Which cart weight based plugin do I need?

    Site:  www.oik-plugins.com
    © Copyright oik-plugins 2011-2025. All rights reserved.


    Website designed and developed by Herb Miller of Bobbing Wide
    Proudly powered by WordPress and oik-plugins

    WordPress version: 6.8.3

    Gutenberg version: 21.7.0

    PHP version: 8.2.29