Skip to content

Commit

Permalink
Place either copyright or caption as below image with caption taking …
Browse files Browse the repository at this point in the history
…precedence.
  • Loading branch information
turnermm committed Apr 15, 2021
1 parent 612cc06 commit a5ec69e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
7 changes: 6 additions & 1 deletion action.php
Expand Up @@ -217,10 +217,12 @@ function ($matches) {
elseif(!$useFileName && !empty($_title)) {
$matches[0] .= trim($_title);
}

$captionpos = $this->getConf('captionpos');
if(in_array('Caption', $this->toolTipOptions)) {
$caption = $this->getFieldValue('Caption',$meta);
if(!empty($caption) && $caption != $_title) {
$matches[0] .= '" data-caption ="' . $this->format_attribute($caption);
$matches[0] .= '" data-caption ="' . "$captionpos::" . $this->format_attribute($caption);
}
}
if($camera) {
Expand All @@ -234,6 +236,9 @@ function ($matches) {

if(!empty($copy)) {
$copypos = trim($this->getConf('copypos'));
if($captionpos == 'screen') {
$copypos = 'tooltip';
}
$matches[0] .= '" license="' . "$copypos::" .$this->format_attribute($copy);
}
$matches[0] = preg_replace("/data-/","\n data-",$matches[0]);
Expand Down
3 changes: 2 additions & 1 deletion conf/default.php
Expand Up @@ -5,4 +5,5 @@
$conf['date_style'] = "date_hms";
$conf['time_format'] = 'hour.min.sec';
$conf['fields'] = 'File,Copyright';
$conf['copypos'] = 'tooltip';
$conf['copypos'] = 'tooltip';
$conf['captionpos'] = 'on-screen';
3 changes: 2 additions & 1 deletion conf/metadata.php
Expand Up @@ -6,4 +6,5 @@
$meta['enable_real'] = array('onoff');
$meta['date_style'] = array('multichoice','_choices'=>array('date_hms','date_hm', 'date','none'));
$meta['time_format'] = array('multichoice','_choices'=>array('hour.min.sec','hour-min-sec','hour_min_sec'));
$meta['copypos'] = array('multichoice','_choices'=>array('tooltip','on-screen','both'));
$meta['copypos'] = array('multichoice','_choices'=>array('tooltip','on-screen','both'));
$meta['captionpos'] = array('multichoice','_choices'=>array('tooltip','on-screen'));
38 changes: 33 additions & 5 deletions script.js
@@ -1,6 +1,7 @@


jQuery( document ).ready(function() {

jQuery("img.media,img.mediacenter,img.mediaright" ).each (function( index ) {
var date, output="",title = "";
var url = jQuery( this ).parent().attr('href');
Expand All @@ -10,16 +11,26 @@
var imgsize = jQuery( this ).parent().attr('data-size');
var fileSize = jQuery( this ).parent().attr('data-fsize');
var width = jQuery( this ).attr('width');
var copypos;
var copypos, captionpos;
if(caption) {
var ar = place_caption(caption.split('::'), this);
caption = ""; ;
captionpos = ar[0];
}
if(copy) {
var ar = copy.split('::')
if(captionpos == 'on-screen') {
copypos = 'tooltip';
copy = copy.replace(/^::/,"");
}
else {
var ar = place_caption(copy.split('::'), this);
copy = ar[1];
copypos = ar[0];
if(copypos.match(/on-screen|both/)) {
jQuery( this ).parent().append('<p class="mtip_copy">' + copy + '</p>');
if(width) jQuery("p.mtip_copy").css("max-width", parseInt(width) +8);
}


}

var title = jQuery( this ).parent().attr('title');
if(camera) {
var tarray = title.match(/_(\d\d[.\-_]\d\d([.\-_]\d\d)?)_/);
Expand Down Expand Up @@ -55,6 +66,9 @@
if(copy && !copypos.match(/tooltip|both/)) {
copy = "";
}
if(caption && !captionpos.match(/tooltip/)) {
caption = "";
}
output = caption ? (title + '<br />' + caption): title;
output = copy ? (output + '<br />' + copy ): output;

Expand All @@ -75,6 +89,20 @@
});
});

function place_caption(ar, obj) {
var width = jQuery( obj ).attr('width');
text = ar[1];
pos = ar[0];

if(pos.match(/on-screen|both/)) {
console.log(text);
console.log(pos);
jQuery( obj ).parent().append('<p class="mtip_copy">' + text + '</p>');
if(width) jQuery("p.mtip_copy").css("max-width", parseInt(width) +8);
}

return ar;

}


0 comments on commit a5ec69e

Please sign in to comment.