Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2014 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3ab33015f5fe0fc113a6 to your computer and use it in GitHub Desktop.
Save anonymous/3ab33015f5fe0fc113a6 to your computer and use it in GitHub Desktop.
Tile Plus Image
<?php if ( $atts['show_image'] ) { ?>
<div style="float: left; margin-right: 10px;">
<?php // ADDED TO WRAP IMAGES WITH URL
$anchor = cnURL::permalink( array(
'type' => $atts['target'],
'slug' => $entry->getSlug(),
'title' => $entry->getName( $atts ),
'text' => $out,
'home_id' => $entry->directoryHome['page_id'],
'force_home' => $entry->directoryHome['force_home'],
'return' => TRUE,
)
);
preg_match( '/href="(.*?)"/', $anchor, $matches );
$url = $matches[1]; ?>
<a target=_blank href="<?php echo $url ?>">
<?php
$entry->getImage( array(
'image' => $atts['image'] ,
'height' => $atts['image_height'] ,
'width' => $atts['image_width'] ,
'fallback' => array(
'type' => $atts['image_fallback'] ,
'string' => $atts['str_image']
)
)
);
?>
</a>
</div>
<?php } ?>
@shazahm1
Copy link

I did have two typos ... darn you copy/paste!

here's the correct code!

    <?php if ( $atts['show_image'] ) { ?>

        <div style="float: left; margin-right: 10px;">
            <?php // ADDED TO WRAP IMAGES WITH URL
      $anchor = cnURL::permalink( array(
      'type' => 'name',
      'slug' => $entry->getSlug(),
      'title' => $entry->getName( $atts ),
      'home_id' => $entry->directoryHome['page_id'],
      'force_home' => $entry->directoryHome['force_home'],
      'return' => TRUE,
      )
      );

      preg_match( '/href="(.*?)"/', $anchor, $matches );
      $url = $matches[1]; ?>


           <a target=_blank href="<?php echo $url ?>">
            <?php

            $entry->getImage( array(
                'image'    => $atts['image'] ,
                'height'   => $atts['image_height'] ,
                'width'    => $atts['image_width'] ,
                'fallback' => array(
                    'type'     => $atts['image_fallback'] ,
                    'string'   => $atts['str_image']
                    )
                )
            );

            ?>
            </a>


        </div>

    <?php } ?>

@shazahm1
Copy link

shazahm1 commented Apr 9, 2015

Update to use the new helper method introduced in Connections 8.1.6...

<?php if ( $atts['show_image'] ) : ?>

    <div style="float: left; margin-right: 10px;">

        <a target=_blank href="<?php echo $entry->getPermalink(); ?>">

            <?php $entry->getImage(
                array(
                    'image'    => $atts['image'] ,
                    'height'   => $atts['image_height'] ,
                    'width'    => $atts['image_width'] ,
                    'fallback' => array(
                        'type'     => $atts['image_fallback'] ,
                        'string'   => $atts['str_image']
                        )
                )
            ); ?>

        </a>

    </div>

<?php endif; ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment