Support

Account

Home Forums Add-ons Gallery Field Extend Class acf_field_gallery render_field() function

Solving

Extend Class acf_field_gallery render_field() function

  • Hi, I want to change the layout structure of gallery while checking the code i found render_field() create all the html, So i want to know that there is any way through which i can change the gallery layout without effecting the gallery core functionality.

  • As far as I know you cannot extend the field types. Well, you could probably extend the class, but since ACF will not instantiate the new class it will you will not be able to override functions in the gallery field class because ACF will be calling the methods in it’s field object and not yours. To to this you would need to create a custom field type https://www.advancedcustomfields.com/resources/creating-a-new-field-type/.

    What is it that you want to change about the gallery field?

  • I wanna show all images of gallery (one by one) to one user with checkbox option to select images and submit form. On Admin panel, Admin can see the selected images with tick sign on each images under the post.

    I try to create new Field by copying all the code of ‘acf_field_gallery’ class but ajax didnot work on clicking ‘Add to Gallery’ button.

  • I’m not sure that just copying the code from the gallery field will work. You’d need to work that code into the class the developer has provided for creating custom field types. A lot of the core fields do not work the same way that class functions.

    If I were doing this I would use a repeater field for this rather than a gallery field. But then I’m not sure I completely understand what you’re doing. You might also be able to do this using a checkbox field where the labels for the fields are the images so that they can be selected.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Extend Class acf_field_gallery render_field() function’ is closed to new replies.