GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Wordpresss modification question (https://gfy.com/showthread.php?t=1108852)

rogueteens 05-08-2013 03:12 AM

Wordpresss modification question
 
When I add media I have the option to link the attachment to a variety of options (custom url, media file, that type of thing) but where in the WP back end can I find the code that controls this? I want to make it so that clicking on the image opens in a new window.

Cheers

purecane 05-08-2013 05:01 AM

on mine when you add the custom url, it has a box to check for either new window or same page....

rogueteens 05-08-2013 05:10 AM

Quote:

Originally Posted by purecane73 (Post 19616236)
on mine when you add the custom url, it has a box to check for either new window or same page....

I don't think you do from the "Insert Media" > "Upload Files" > "Attachment Display Settings" page, which is what I want to modify.

purecane 05-08-2013 05:26 AM

yep, you're right...i see now.

TrashyGirl 05-08-2013 07:02 AM

You used to be able to do this by clicking on the image in "Edit Media" and then clicking on the "Advanced Settings" and clicking a box for Target - Open in a New Window. But I don't see this feature w/ the new WP update that changed image handling. I think it can be done for galleries using NextGen Gallery plugin.

The coding issue would be that the images set in each post are specific content to each post as far as how I understand WP. So maybe Fris or someone else can advise you the code to insert to loop thru the posts, use regex to grab the images and code them to open t\ blank ??? :helpme

Fetish Gimp 05-08-2013 08:32 AM

Quote:

Originally Posted by rogueteens (Post 19616136)
When I add media I have the option to link the attachment to a variety of options (custom url, media file, that type of thing) but where in the WP back end can I find the code that controls this? I want to make it so that clicking on the image opens in a new window.

Cheers

Haven't tried this myself, but looks like it might do what you want
http://wordpress.org/extend/plugins/...-custom-links/

rogueteens 05-08-2013 11:08 AM

I don't think that'll work.
I really did think it would just be a simple line modification in one of the files?

iwantchixx 05-08-2013 01:57 PM

Do you want all pics to act like this, if so why not just use a lightbox?

harvey 05-08-2013 02:00 PM

Quote:

Originally Posted by iwantchixx (Post 19616965)
Do you want all pics to act like this, if so why not just use a lightbox?

this

anyway, you could also use http://wordpress.org/extend/plugins/...window-plugin/

rogueteens 05-08-2013 02:18 PM

Quote:

Originally Posted by iwantchixx (Post 19616965)
Do you want all pics to act like this, if so why not just use a lightbox?

It doesn't work with the theme i'm using. it shows the pictures full size and I have them clickable to go to sponsors and I want the click to open in a new window.

Quote:

Originally Posted by harvey (Post 19616969)

that seems like a heck of a lot of mucking around just to get the image opening in a new window, I think it might muck up other stuff I have on my blog too but thanks anyway.

Colmike9 05-08-2013 02:32 PM

Code:

<?php
/* Plugin Name: (#50911) Open gallery img in new window/tab */

add_action( 'after_setup_theme', 'wpse50911_replace_img_shortcodes' );
function wpse50911_replace_img_shortcodes()
{
    remove_shortcode( 'gallery', 'gallery_shortcode' );
    add_shortcode( 'gallery', 'wpse50911_gallery_shortcode' );

    remove_shortcode( 'caption', 'img_caption_shortcode' );
    add_shortcode( 'caption', 'wpse50911_caption_shortcode' );

    remove_shortcode( 'wp_caption', 'img_caption_shortcode' );
    add_shortcode( 'wp_caption', 'wpse50911_caption_shortcode' );
}
function wpse50911_gallery_shortcode( $attr )
{
    return links_add_target( gallery_shortcode( $attr ) );
}
function wpse50911_caption_shortcode( $attr, $content = null)
{
    return img_caption_shortcode( $attr, links_add_target( $content ) );
}
?>


duk75 05-08-2013 02:37 PM

TARGET="_blank"

rogueteens 05-08-2013 03:04 PM

Quote:

Originally Posted by Colmike7 (Post 19617022)
Code:

<?php
/* Plugin Name: (#50911) Open gallery img in new window/tab */

add_action( 'after_setup_theme', 'wpse50911_replace_img_shortcodes' );
function wpse50911_replace_img_shortcodes()
{
    remove_shortcode( 'gallery', 'gallery_shortcode' );
    add_shortcode( 'gallery', 'wpse50911_gallery_shortcode' );

    remove_shortcode( 'caption', 'img_caption_shortcode' );
    add_shortcode( 'caption', 'wpse50911_caption_shortcode' );

    remove_shortcode( 'wp_caption', 'img_caption_shortcode' );
    add_shortcode( 'wp_caption', 'wpse50911_caption_shortcode' );
}
function wpse50911_gallery_shortcode( $attr )
{
    return links_add_target( gallery_shortcode( $attr ) );
}
function wpse50911_caption_shortcode( $attr, $content = null)
{
    return img_caption_shortcode( $attr, links_add_target( $content ) );
}
?>


thank you very much :)

fris 05-10-2013 11:26 AM

you can make it default to the url of the image

Code:

add_filter( 'attachment_link', 'direct_image_urls_for_galleries', 10, 2 );

function direct_image_urls_for_galleries( $link, $id ) {
        if ( is_admin() ) return $link;

        $mimetypes = array( 'image/jpeg', 'image/png', 'image/gif' );

        $post = get_post( $id );

        if ( in_array( $post->post_mime_type, $mimetypes ) )
                return wp_get_attachment_url( $id );
        else
                return $link;
}

not sure if thats what you want.


All times are GMT -7. The time now is 07:37 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc