Copyright/Custom field in gallery

Posted in: Newsmag
Post count: 217

Hi,

how can I show the content of an already existing copyright-field in the gallery?

The custom field is implementet via functions.php in the media uploader. Can you help me please? Thanks!

/**
* Copyrightfeld
*/

function be_attachment_field_credit( $form_fields, $post ) {
$form_fields['be-photographer-name'] = array(
'label' => 'Copyright',
'input' => 'text',
'value' => get_post_meta( $post->ID, 'be_photographer_name', true ),
);

return $form_fields;
}

add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );

/**
* Save values of Photographer Name and URL in media uploader
*
* @param $post array, the post data for database
* @param $attachment array, attachment fields from $_POST form
* @return $post array, modified post data
*/

function be_attachment_field_credit_save( $post, $attachment ) {
if( isset( $attachment['be-photographer-name'] ) )
update_post_meta( $post['ID'], 'be_photographer_name', $attachment['be-photographer-name'] );

return $post;
}

add_filter( 'attachment_fields_to_save', 'be_attachment_field_credit_save', 10, 2 );

Post count: 217

Basically I only need to exchange the image CAPTION for the copyright, but I don’t know how and in which file. Can you help me please?

Thank you!

Post count: 217

I think I found the part in the td_wp_booster_functions.php, but I don’t know what to change.

//check if we have all the images
if(!empty($td_temp_image_url[0]) and !empty($td_temp_image_url_80x60[0]) and !empty($td_temp_image_url_full)) {

//css for display the small cursor image
$slide_images_thumbs_css .= '
#' . $gallery_slider_unique_id . ' .td-doubleSlider-2 .td-item' . $cur_item_nr . ' {
background: url(' . $td_temp_image_url_80x60[0] . ') 0 0 no-repeat;
}';

//html for display the big image
$class_post_content = '';

if(!empty($image_attachment['description']) or !empty($image_attachment['caption'])) {
$class_post_content = 'td-gallery-slide-content';
}

//if picture has caption & description
$figcaption = '';

if(!empty($image_attachment['caption']) or !empty($image_attachment['description'])) {
$figcaption = '<figcaption class = "td-slide-caption ' . $class_post_content . '">';

if(!empty($image_attachment['caption'])) {
$figcaption .= '<div class = "td-gallery-slide-copywrite">' . $image_attachment['caption'] . '</div>';
}

if(!empty($image_attachment['description'])) {
$figcaption .= '<span>' . $image_attachment['description'] . '</span>';
}

$figcaption .= '</figcaption>';
}

$slide_display_html .= '
<div class = "td-slide-item td-item' . $cur_item_nr . '">
<figure class="td-slide-galery-figure td-slide-popup-gallery">

' . htmlentities($image_attachment['alt'], ENT_QUOTES) . '

' . $figcaption . '
</figure>
</div>';

Post count: 6600

Hi,

The image caption is stored here $image_attachment['caption']. Try to replace this with your custom filed.

Thanks

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newsmag’ is closed to new topics and replies.