WordPress.org

Ready to get started?Download WordPress

Forums

Codepress Admin Columns
[resolved] Feature Suggestion - Images based on Media ID (5 posts)

  1. robgundling
    Member
    Posted 1 year ago #

    Great plugin - Just discovered it and also got your Sort Order addon - saved me a bunch of programming time.

    I have an image in a "Front Page Slides" custom post type that returns a media ID for an image and not a URL where I want to show a scaled down pic in the back end.

    Would be great to show the image using the built in wp_get_attachment_image( $id, $size ) function with an optional size specification.

    Right now, I'm cheating and using the thumbnail view using "media library icon" as the way to view.

    Anyway.. thanks again for a great plugin...

    http://wordpress.org/extend/plugins/codepress-admin-columns/

  2. Tobias Schutter
    Member
    Plugin Author

    Posted 1 year ago #

    Your image ID is stored in a custom field. So you are doing it correctly by using the "media library icon" from the custom field box.

    You can also set your own image size. Only not within the UI, you will have to add this to your themes functions.php in order to set your own size preference:

    add_filter('cpac_thumbnail_size','my_custom_thumbsize');
    function my_custom_thumbsize()
    {
         // width, height
         return array(30,30);
    }

    or

    add_filter('cpac_thumbnail_size','my_custom_thumbsize');
    function my_custom_thumbsize()
    {
         // or any other preset image size you have set, like thumbnail, medium, large etc.
         return 'medium';
    }
  3. robgundling
    Member
    Posted 1 year ago #

    I see you added a custom hook in there in the Plugin update... awesome!

    Thanks for the response! Implementing now...

  4. robgundling
    Member
    Posted 1 year ago #

    I have been able to implement the hook. The only issue I have is that it is only giving me "square" thumbnails to display. Any hints on how I could do something like 194x63 px?

  5. Tobias Schutter
    Member
    Plugin Author

    Posted 1 year ago #

    The problem is that the new imagesize (194x63) is not available. WordPress then looks for the closest available size which is the actual thumbnail.

    To show the correct size you will have to add the image size, like so:

    add_image_size('my-thumbnail-size', 194, 63);

    For the full code use this:

    // edit here: fill in your thumbnail height and width
    $my_height = 63;
    $my_width  = 194;
    // stop editing
    
    add_image_size( 'admin-columns-thumb', $my_width, $my_height, true );
    add_filter('cpac_thumbnail_size', function() {
    	return 'admin-columns-thumb';
    });

    I will add this to make FAQ aswell.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.