/** * Flickr: metadata */ function credittracker_get_flickr_metadata($number) { $parser = new CTFlickr(credittracker_get_single_option('ct_auth_flickr_apikey')); return $parser->execute($number); }
function credit_tracker_caption_shortcode_filter($val, $attr, $content = null) { extract(shortcode_atts(array('id' => '', 'align' => 'aligncenter', 'width' => '', 'caption' => '', 'text' => '', 'type' => 'caption'), $attr)); $ct_override_caption_shortcode = credittracker_get_single_option('ct_override_caption_shortcode'); if ((bool) $ct_override_caption_shortcode) { $id_orig = $id; if ($id) { $id = esc_attr($id); } // extract attachment id preg_match("/\\d+/", $id, $matches); if (!empty($matches)) { $id = $matches[0]; } // find attachment $request = array('size' => 'thumbnail', 'include' => $id); $images = credittracker_get_images($request); if (empty($images)) { return $val; } $image = reset($images); $ct_copyright_format = credittracker_get_source_copyright($image['source']); if (empty($ct_copyright_format)) { $ct_copyright_format = credittracker_get_single_option('ct_copyright_format'); } // override image caption via 'text' attribute if (!empty($text)) { $image['caption'] = $text; } $ct_copyright = htmlspecialchars_decode(credittracker_process_item_copyright($image, $ct_copyright_format)); $content = str_replace('<img', '<img itemprop="contentUrl"', $content); $style = ''; if ((int) $width > 0) { $style = 'style="width: ' . (int) $width . 'px"'; } $ret = '<div id="' . $id_orig . '" class="wp-caption credit-tracker-caption ' . esc_attr($align) . '" itemscope itemtype="http://schema.org/ImageObject" ' . $style . '>'; $ret .= do_shortcode($content); $ret .= '<p class="wp-caption-text" itemprop="copyrightHolder">' . $ct_copyright . '</p>'; $ret .= '<meta itemprop="name" content="' . $image['title'] . '">'; $ret .= '<meta itemprop="caption" content="' . $image['caption'] . '">'; $ret .= '<meta itemprop="author" content="' . $image['author'] . '">'; $ret .= '<meta itemprop="publisher" content="' . $image['publisher'] . '">'; $ret .= '</div>'; return $ret; } else { return $val; } }
public function get_attachment_fields($form_fields, $post) { $selected_source = get_post_meta($post->ID, "credit-tracker-source", true); $ct_retriever_enabled = credittracker_get_single_option('ct_feature_retriever'); $form_fields["credit-tracker-ident_nr"] = array("label" => __('Ident-Nr.', CREDITTRACKER_SLUG), "input" => "text", "value" => get_post_meta($post->ID, "credit-tracker-ident_nr", true), "helps" => __("The original object number at the source", CREDITTRACKER_SLUG)); if ($ct_retriever_enabled == '1') { $btn_state = ''; $link_activate = ""; } else { $btn_state = 'disabled'; $link_activate = "<a href='" . admin_url('options-general.php?page=credit-tracker') . "'>" . __("activate", CREDITTRACKER_SLUG) . "</a>"; } // Note: only attachment (media edit) page is enabled at the moment for the media data retrieval $screen = get_current_screen(); $ct_btn_allowed_screens = array("attachment"); if (isset($screen) && in_array($screen->id, $ct_btn_allowed_screens)) { $btn_retriever_code = " <button id='ct-mediadata' type='button' " . $btn_state . ">" . __("GET MEDIA DATA", CREDITTRACKER_SLUG) . "</button>" . " " . $link_activate; } else { $btn_retriever_code = ''; } $form_fields["credit-tracker-source"] = array("label" => __('Source', CREDITTRACKER_SLUG), "input" => "html", "value" => $selected_source, "html" => "<select name='attachments[{$post->ID}][credit-tracker-source]' id='attachments-{$post->ID}-credit-tracker-source'>" . credittracker_get_combobox_options(credittracker_get_sources_names_array(), $selected_source) . "</select>" . $btn_retriever_code, "helps" => __("Source where to locate the original media", CREDITTRACKER_SLUG)); $form_fields["credit-tracker-author"] = array("label" => __('Author', CREDITTRACKER_SLUG), "input" => "text", "value" => get_post_meta($post->ID, "credit-tracker-author", true), "helps" => __("Media author/owner", CREDITTRACKER_SLUG)); $form_fields["credit-tracker-publisher"] = array("label" => __('Publisher', CREDITTRACKER_SLUG), "input" => "text", "value" => get_post_meta($post->ID, "credit-tracker-publisher", true), "helps" => __("Media publisher (e.g. image agency)", CREDITTRACKER_SLUG)); $form_fields["credit-tracker-license"] = array("label" => __('License', CREDITTRACKER_SLUG), "input" => "text", "value" => get_post_meta($post->ID, "credit-tracker-license", true), "helps" => __("Media license", CREDITTRACKER_SLUG)); $form_fields["credit-tracker-link"] = array("label" => __('Link', CREDITTRACKER_SLUG), "input" => "text", "value" => get_post_meta($post->ID, "credit-tracker-link", true), "helps" => __("Media link", CREDITTRACKER_SLUG)); return $form_fields; }