• Resolved jejonesjnr

    (@jejonesjnr)


    I have a custom post type which has several image fields. When I create a form which allows attachments and link those fields to the ACF image fields, the images don’t embed. Instead, when I view the post, the image fields say “no image selected”. Is there something else I need to do?

Viewing 13 replies - 31 through 43 (of 43 total)
  • Thread Starter jejonesjnr

    (@jejonesjnr)

    I have amended the code in the mu-plugin folder and made sure all the images are set to show in media library. The post is still showing no image selected however, as you can see from the link below, the URL for the image is being stored in the database.

    https://1drv.ms/i/s!AsElALC9XunfmHQQRzdwhx12kZQD?e=Ca2Ir8

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @jejonesjnr,

    Sorry to hear its still an ongoing issue, I’m bringing this further to our developers attention to check further regarding this and will get back to you once we get further feedback asap.

    Best Regards,

    Nithin

    Thread Starter jejonesjnr

    (@jejonesjnr)

    I have managed to resolve the issue by creating a custom shortcode in elementor which take the value and wraps the img src tags around it.

    I have had to convert the image fields to text in order to accomplish this however, it now does what I need it to do.

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @jejonesjnr,

    I have managed to resolve the issue by creating a custom shortcode in elementor which take the value and wraps the img src tags around it.

    Glad to hear you have managed to find a workaround, however, you can also try this updated snippet by replacing the previous code given on your website and see whether it helps with the issues noticed:

    <?php
    
    add_action( 'forminator_post_data_field_post_saved', 'wpmudev_update_post_acf_upload', 10, 4 );
    function wpmudev_update_post_acf_upload( $post_id, $field, $data, $cls ) {
    	// comma separated list of image fields
    	$image_fields = array( 'image_two', 'image_three', 'image_four', 'image_five', 'image_six', 'image_seven', 'image_eight', 'image_nine', 'image_ten' ); 
    
    	if( isset( $data['post-custom'] ) ){
    		foreach( $data['post-custom'] as $pkey => $pval ){
    			
    			if ( in_array( $pval['key'], $image_fields ) ) {
    			
    				if( $pval['value'] ) {
    				    $orig_url = $pval['value'];
                        $temp_url = replace_between($orig_url, 'forminator/', 'uploads/', 'temp/'); 
                        $temp_url = str_replace( 'temp/uploads', 'temp', $temp_url );
    					$attach_id = attachment_url_to_postid( $temp_url );
    					if( $attach_id ) {
    						update_field($pval['key'], $attach_id, $post_id);
    						$mime_type = wp_get_image_mime( $pval['value'] );
    						if( $mime_type ) {
    							$update_data = array(
    								'ID' => $attach_id,
    								'post_mime_type' => $mime_type,
    							);
    							wp_update_post( $update_data );
    						}
    					}
    				}
    			}
    		}
    	}
    }
    
    function replace_between($str, $needle_start, $needle_end, $replacement) {
        $pos = strpos($str, $needle_start);
        $start = $pos === false ? 0 : $pos + strlen($needle_start);
    
        $pos = strpos($str, $needle_end, $start);
        $end = $pos === false ? strlen($str) : $pos;
    
        return substr_replace($str, $replacement, $start, $end - $start);
    }

    You can apply the code as a mu-plugins as instructed before.

    Kind Regards,

    Nithin

    Thread Starter jejonesjnr

    (@jejonesjnr)

    Sorry to report that this didn’t work either. What version of Forminator are you testing this on?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jejonesjnr

    We are always testing with the current, up to date versions of plugins (unless it’s specifically stated that the issue applies to some older version). At the moment it’s 1.24.1 release – though since the ticket is already quite long, we might also have been testing with previous release earlier. In general though: it’s always current version at the moment unless explicitly stated otherwise.

    Kind regards,
    Adam

    Thread Starter jejonesjnr

    (@jejonesjnr)

    That’s fine. I was applying the code to version 1.24.1. I was just checking.

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jejonesjnr

    Thanks for response!

    I’m not really sure what we could do more in this case then. It seems we are still missing something specific to your site’s configuration but I honestly don’t know what that could be.

    I’m sorry we couldn’t help you better but I’d say that if the workaround that you found works fine for you, it may be a good idea to just stick to that in this case.

    Kind regards,
    Adam

    Thread Starter jejonesjnr

    (@jejonesjnr)

    It is very frustrating however, I would like to thank you and the team for the effort taken in trying to resolve this for me.

    I have kept the code snippets any may try on another test site with limited plugins to see of there’s a conflict elsewhere. I will feedback if I find anything.

    One thing just for clarification though, I do have all the image fields in ACF set to image_ID. I assume this is correct?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @jejonesjnr

    Actually, ACF image field setting shouldn’t be related anymore – apparently it always stores it as image IDs and the setting only changes how it outputs it. So any custom code would need to store image IDs anyway.

    I know I have myself suggested setting ACF to image IDs in the past but it seems it’s no longer necessary as far as I’m aware. i was sure I mentioned it somewhere on the course of this ticket but apparently I did not – I’m sorry about that.

    Kind regards,
    Adam

    Thread Starter jejonesjnr

    (@jejonesjnr)

    No problem. Thanks for the response.

    Thread Starter jejonesjnr

    (@jejonesjnr)

    Just to advise that the latest version of the code snippet you sent seems to work now in attaching the images to the custom post. Many thanks again for all the help. The support has been outstanding.

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @jejonesjnr,

    I hope you are doing well today and we are happy to hear that the issue has been resolved and marking this thread accordingly.
    Please let us know in case you need further help.

    Kind regards,
    Zafer

Viewing 13 replies - 31 through 43 (of 43 total)
  • The topic ‘Issue with images’ is closed to new replies.