WordPress.org

Ready to get started?Download WordPress

Forums

creating link to large/medium image while inserting in text (6 posts)

  1. matejl
    Member
    Posted 4 years ago #

    When I', inserting image in text (inline through visual editor) there is text field for "Link URL" with three buttons (none, file url, post url).

    I want to make a link to resized image (medium or large), because original is usualy to big.

    I know, I cau use "Post Url", but I need just image url, to show images in lightbox.

    As I understand the code I think I need function similar to wp_get_attachment_thumb_url (wp_get_attachment_medium_url), but I lost myself while trying to make it.

    thanks, for you help

  2. matejl
    Member
    Posted 4 years ago #

    Found the solution ... you need to edit wp-admin/includes/media.php

    function image_link_input_fields($post, $url_type = '') {
    
    	//$file = wp_get_attachment_url($post->ID);
    	$aFile = wp_get_attachment_image_src($post->ID, 'large');
    	$file = $aFile[0];
    
    	$link = get_attachment_link($post->ID);
    	...

    Problem with this solution is if you modify image (reupload image with different dimensions) the link will become invalid.

  3. physalis
    Member
    Posted 3 years ago #

    Is there an update on this matter? Does anyone know a plugin or something enabling us to choose to link to another image than the full size one?

  4. mushon
    Member
    Posted 3 years ago #

    I would love some tip on this one as well...

  5. talie2
    Member
    Posted 3 years ago #

    How is it that there's still no plugin for this - or better yet it's not a built in WP feature??

  6. hd.design
    Member
    Posted 3 years ago #

    There is an easy way to add an additional button with a filter in your functions.php template file...

    Solution by Oleg Butuzov

    I'm playing around with this filter to make 'medium image' and 'none' the only two options.

Topic Closed

This topic has been closed to new replies.

About this Topic