Skip to content

Commit

Permalink
Wrap our media credit in the media credit url if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Darby committed Jul 16, 2019
1 parent fe1292b commit 0660b38
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions js/blocks-image-customization.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,25 @@ var largo_core_image_block_add_media_credit = createHigherOrderComponent( functi

if( media.media_credit && media.media_credit._media_credit ){

// our default media credit, if it exists
var media_credit = '<p class="wp-media-credit">' + media.media_credit._media_credit + '</p>';
var media_credit = media.media_credit._media_credit;

// if our media credit has a url, include that also
// if the media credit organization exists, add it
if( media.media_credit._navis_media_credit_org ){

var media_credit = '<p class="wp-media-credit">'+media.media_credit._media_credit+' / '+media.media_credit._navis_media_credit_org+'</p>';
var media_credit = media.media_credit._media_credit+' / '+media.media_credit._navis_media_credit_org;

}

// if the media credit url exists, wrap the media credit with it
if( media.media_credit._media_credit_url ){

var media_credit = '<a href="'+media.media_credit._media_credit_url+'">'+media_credit+'</a>';

}

// our full media credit
var media_credit = '<p class="wp-media-credit">'+media_credit+'</p>';

// if our media attachment caption already includes `largo-attachment-media-credit`,
// which is the class of our span, don't do anything more
if( ! attachment_caption.includes( 'wp-media-credit' ) ){
Expand Down

0 comments on commit 0660b38

Please sign in to comment.