Hi,
I don't want to use types API. I need get_post_meta for image-field.
get_post_meta( $id, "wpcf-img-field",true );
Img field has single value, therefore is "true" in get_post_meta. I get also IMG src from database, but problem is, that in IMG SRC are german characters. e.g. hidden link and this cannot render correct in html, therefore I cannot see IMG. Also in src is "–" (Mac Dash with ALT+Dash or html "en dash") -> marked bold. How can I get and render images src in html correct ?
I tried utf8_decode( get_post_meta($szbID,"wpcf-szenenbild",true) ); but this renders "en dash" as "?"
best regards
Hi, I will be glad to help but I need some more information. Here's what I did to try to replicate a problem with an img src URL containing special characters.
First I created an image file using the same name you provided. Please find the file attached.
Then I added the image as a custom field in a post. My field slug is "img-1". I added this content to a post in the "text" tab:
Types field: [types field='img-1' separator=', ' output='raw'][/types]<br />
SRC shortcode: [german_src]<br />
Image with src shortcode: <img src="[german_src]" /><br />
To test it out, I created a custom shortcode "german_src" using this PHP:
add_shortcode( 'german_src', 'german_src_func' );
function german_src_func() {
$src = get_post_meta(310, 'wpcf-img-1', true);
return $src;
}
My post ID is 310. So you can see that I'm returning the URL of the image to be used as the src attribute in an img tag. It seems to be working for me. Please find the results attached as a screenshot. I don't see a problem with the image src attribute, so I must be missing something. Can you help me replicate the problem?
Hi Christian,
you are right, this does work. I tested und checked my HTML and problem was, that I had not meta charset on my website. I added <meta charset="UTF-8"> and now everything works very well.
best regards