• Resolved snupijenta

    (@snupijenta)


    Hi!

    I was so happy when I found your plugin! I´ve tried so many different plugins, without getting the result that I need, and so far it seemed like this one had it all.

    BUT it had to turn up a little problem.

    You see; on one of the pages where I added the gallery-to-slideshow, I want the pictures to work as links to other pages on the same website. But I can´t make it work…:(

    Actually, what I REALLY would like, was if there was a possibility to have a description-field with some info from the linked-up page, and a Read More button that links the picture to an other page… Just like the “featured slider” does in this theme: http://www.elegantthemes.com/demo/?theme=Chameleon

    I have tried to use some of the codes from the featured.php and stylesheet.css to configure something like that to your plugin, but after all: I AM a newbie, and I´m not a programmer/developer of cool stuff like this, -so I struggle.

    If there´s not any possibility to make a descritption-read-more-link-to-other-page-thingy for the gallery-to-slideshow plugin, I would be most grateful for only a possibility to LINK the images to other pages…
    I HAVE tried to make a link in the Page-Add Media-Gallery settings, but it doesn´t allow any other thing than link to the image itself..

    Please help me.. I´m so tired of this never-ending slideshowgallery problems of mine……..

    http://wordpress.org/extend/plugins/gallery-to-slideshow/

Viewing 1 replies (of 1 total)
  • I don’t know if you’re still looking for this solution but here’s what I’ve done:

    In my child theme’s functions.php

    /* For adding custom field to gallery popup */
    function pj_image_attachment_fields_to_edit($form_fields, $post) {
    	// $form_fields is a an array of fields to include in the attachment form
    	// $post is nothing but attachment record in the database
    	//     $post->post_type == 'attachment'
    	// attachments are considered as posts in WordPress. So value of post_type in wp_posts table will be attachment
    	// now add our custom field to the $form_fields array
    	// input type="text" name/id="attachments[$attachment->ID][custom1]"
    	$form_fields["pj-image-link"] = array(
    		"label" => __("Custom Link"),
    		"input" => "text", // this is default if "input" is omitted
    		"value" => get_post_meta($post->ID, "_pj-image-link", true),
                    "helps" => __("Shows below the description in galleries with 'see more'."),
    	);
       return $form_fields;
    }
    // now attach our function to the hook
    add_filter("attachment_fields_to_edit", "pj_image_attachment_fields_to_edit", null, 2);
    
    function pj_image_attachment_fields_to_save($post, $attachment) {
    	// $attachment part of the form $_POST ($_POST[attachments][postID])
            // $post['post_type'] == 'attachment'
    	if( isset($attachment['pj-image-link']) ){
    		// update_post_meta(postID, meta_key, meta_value);
    		update_post_meta($post['ID'], '_pj-image-link', $attachment['pj-image-link']);
    	}
    	return $post;
    }
    // now attach our function to the hook.
    add_filter("attachment_fields_to_save", "pj_image_attachment_fields_to_save", null , 2);

    This goes in gallery-to-slideshow-class.php where the caption html output is being constructed.

    $image_link = get_post_meta($attachment->ID, '_pj-image-link', true);	// Perry Johnson edit
                            $output .= '<p class="flex-caption"><span>' . esc_html( $attachment->post_excerpt );
                            if($attachment->post_content != ""){
                            	$output .= ' &mdash; '. $attachment->post_content;
                            }
                            $output .= '</span>';
                            if($image_link != ""){ // Perry Johnson edit
                            	$output .= '<a href="'.$image_link.'" class="slideInfoLink" title="See more details about this one.">➤</a>';
                            }

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Gallery to Slideshow] Make gallery images link to pages’ is closed to new replies.