Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change plupload drag-drop image size from thumbnail to other size #425

Closed
enginne opened this issue Mar 12, 2014 · 1 comment
Closed

Change plupload drag-drop image size from thumbnail to other size #425

enginne opened this issue Mar 12, 2014 · 1 comment

Comments

@enginne
Copy link

enginne commented Mar 12, 2014

Hello there!

I have this plupload meta box which allows only 1 image to upload. So far so good.
The thing is: since only 1 image will be allowed to upload i wanted the thumbnail size of the image displayed to be larger like "large" or "medium". A good sharp image centered by css in the meta box.

I looked through the source code and in the file inc/fields/image.php the function:

function img_html( $image )

on line 148 controls the image size displayed:

    $src  = wp_get_attachment_image_src( $image, 'thumbnail' );

I wanted to change the value "thumbnail" to "medium" or "large" using a hook.

I followed some steps as stated on #141 but can't get it to work.

I basically copied the function and only changed the "thumbnail" to "large".
This is what i have on my functions.php right now:

add_filter( 'rwmb_img_html', 'my_new_size', 10);

function my_new_size( $image )
        {
            $i18n_delete = apply_filters( 'rwmb_image_delete_string', _x( 'Delete', 'image upload', 'rwmb' ) );
            $i18n_edit   = apply_filters( 'rwmb_image_edit_string', _x( 'Edit', 'image upload', 'rwmb' ) );
            $li = '
                <li id="item_%s">
                    <img src="%s" />
                    <div class="rwmb-image-bar">
                        <a title="%s" class="rwmb-edit-file" href="%s" target="_blank">%s</a> |
                        <a title="%s" class="rwmb-delete-file" href="#" data-attachment_id="%s">×</a>
                    </div>
                </li>
            ';

            $src  = wp_get_attachment_image_src( $image, 'large' );
            $src  = $src[0];
            $link = get_edit_post_link( $image );

            return sprintf(
                $li,
                $image,
                $src,
                $i18n_edit, $link, $i18n_edit,
                $i18n_delete, $image
            );
        }

So i replaced "thumbnail" with "large" but nothing happens. Zipp, nada, rien...
The image on the plupload meta box still outputs as thumbnail.

This should be straightforward but i'm kinda new to PHP.

Can anybody be kindly enough to point me in the right direction?

Thanks in advance.

@funkatron82
Copy link
Contributor

Doesn't work because the css that displays the image is set to a specific size (150px x 150px). Looking into adding this feature in a future release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants