Skip Navigation

[Resolved] Gallery Issue since update to latest version

This support ticket is created 5 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.33 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 5 replies, has 2 voices.

Last updated by Nigel 5 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1358891

I am trying to:

Allow users to upload images via Gallery

Issue One:
In new and old version of Toolset, Gallery always breaks the page view if you add more than 10 images. Previously we added javascript code to hide the Add more button, if more than 10 pages exist. This code no longer works, so we'll fix this, but ideally, We would like to display more than 10 images.

Issue Two:
In the new version, the image uploader has changed to the same as WordPress Native. Can see Media libary. How do we revert back to just having an upload button?

Thanks,
Terry.

#1358903

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-10-09 at 12.40.42.png

Hi Terry

Since the update to use the WP Media Uploader (issue 2) you can disable it in a setting in the form, see the screenshot.

I'm not sure I understand issue 1, could you elaborate?

#1358921

Hi,

On issue one, if you add a view that tries to display a gallery with more then 10 images, it breaks the view and shows the shortcodes, instead of rendering them.

Cheers,
Terry.

#1358923

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

What are you using for the gallery?

Can I get more details of how your View is set up?

10 images doesn't sound coincidental, it sounds like the pagination limit.

And if there more than 10 images you have to paginate to the second page of results, but maybe you are using some third party for the gallery, such as a page builder, and it's shortcodes are not instantiated after an ajax update..?

I'm speculating because I don't have any details of how you created a gallery.

#1359443

Thanks, we'll take a look into pagination.

Issue 3 - we are trying to restrict the image file size upload limit to the gallery. This is the code we had before that worked:

add_action( 'cred_form_ajax_upload_validate', 'data_validation', 10, 2 );

function data_validation( $error_fields, $form_data ){

list( $fields, $errors ) = $error_fields;
if ( $form_data['id'] == 623 ) {

if( isset( $fields['wpcf-event-gallery']['field_data']['size'] ) ) {

foreach( $fields['wpcf-event-gallery']['field_data']['size'] as $k => $v ) {

if( $v > 200000 ) {

$errors['event-gallery']='the image size should not be more than 200 kilobytes';
}
}
}
else
{

}
}
else {

}
return array( $fields, $errors );
}

Do you have any ideas as to why this isn't working anymore?

Cheers,
Terry.

#1359599

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Terry

With the change to use the WP Media Uploader, if you use it, I believe that filter should still work.

However, if you disable the WP Media Uploader in the form settings then you no longer have an option to upload images via ajax, they will be uploaded along with the rest of the form content upon submission.

Hence the cred_form_ajax_upload_validate filter isn't run.

Your options would be to use the normal cred_form_validate hook instead (https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate).

Or... use the WP Media Uploader. Why do you not want to use that? It tends to offer a better user experience.

Is it because users can choose from the whole media library? Seeing images which they didn't upload?

If that's the case then you could try the following snippet which what users see in the media library to only their own images:

add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
function show_current_user_attachments( $query = array() ) {

    $user_id = get_current_user_id();
    if( $user_id ) {
        $query['author'] = $user_id;
    }
    return $query;
}

(From From https://codex.wordpress.org/Plugin_API/Filter_Reference/ajax_query_attachments_args#Examples.)

If you have new issues, could you please open new threads?

Thanks.