Test the value before you use it:
<?php
if ( ! $img = get_field('img_actor', get_the_ID() ) )
$img = 'http://www.example.com/wp-content/uploads/default.jpg';
?>
<img class="film"
src="https://wordpress.stackexchange.com/scripts/timthumb.php?src=<?php echo urlencode($img); ?>&h=251&w=175&zc=1"
alt="<?php the_title_attribute(); ?>"
title="<?php the_title_attribute(); ?>"/>
I recommend not to use the same text for title
and alt
, this is very annoying for screen reader users.
Related Posts:
- How to enable custom fields for pages (if not a bad practice)?
- Add a Jquery Datepicker to custom field in post edit
- Custom per-page sidebar widgets .. possible?
- How to add new custom page or post blocks?
- Order Posts by Closest Numeric Values
- Transients vs CRON +Custom Fields: Caching Data Per Post
- How to update serialized data in the user meta data
- Unable to save datetime custom meta field using update_post_meta() function
- Guest Author – How can I use custom fields to create guest author link?
- Create additional short URL with custom field and 301 redirect
- enabling custom fields in admin?
- get_post_meta fields don’t show up on posts page
- Using custom fields in a filter hook
- Function to change meta value in database for each post
- Using WP Query to search by multiple meta fields
- Get aggregate list of all custom fields for entire blog
- How to Identify the Source of a Custom Field?
- Include woocommerce custom field value in front-end search result
- woocommerce product custom field
- How to validate custom field on lost password form before the user id field?
- MySQL Query that looks for post with Custom Field, then changes Category
- two custom fields question
- Woocommerce: Custom fields and email shortcodes, ec_custom_field
- How to save multiple options from a dropdown in user profile
- How to display multiple images in custom field
- How to show a gloabl message on a user profile page (in back end)?
- Create Pop-Up Box with Custom Field Content Inside the Loop
- Display the contents of a custom field of a page on their child
- Adding an editable field to template?
- Transferring author information from a custom field to a proper author
- Read / Watch / Listen times – meta
- Login WP – Connect single field to an external api
- adding extra wordpress user info from registration form
- Custom Meta Box (SELECT) Not Saving
- jQuery – Automatic event trigger does not **really** check my form
- Display URL in a Custom Field
- Linking Custom Fields to Database Records
- Turn raw url into clickable links
- Advanced Custom Fields functionality without plugin
- Get post ids sorted by meta_key
- Advanced Custom Fields Plugin – Unable to get URL from post_object
- Plot location on Google map using full address specified in custom field
- Display custom field value as a hyperlink
- Unable to get specific value from post meta
- pre_get_posts : only get posts by wp_usermeta value
- Display list of terms having the same custom field value
- How to display custom field in woocommerce email orders? [closed]
- Custom meta is not being saved
- Displaying Custom Field Array
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- IF Custom field value equals ZERO
- Custom Field Repeating When Using foreach
- Accessing Custom Fields on Pages
- Can I save post meta programatically without setting metaboxes?
- How to add a css class to custom field value?
- Show custom field on attachment page?
- Help setting up a sql query
- Advanced Custom fields not available yet during publish_page action
- Meta box values are displayed on Custom Fields list. Is it possible to hide them?
- Sort posts by custom field value
- Help with this custom field conditional if no field is set display nothing
- if statement display content even though no data
- How to pass custom field value to shortcode?
- custom comment_form fields not displaying
- Get custom post fields from multiple metaboxes
- Get author total post votes from post meta
- use custom field value as post category in loop
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- Save custom field types with this function…?
- Compare ACF date field (if exists) and post date and order DESC
- How to display custom fields in hestia theme
- How to update only certain custom fields in a the cache of a page?
- pass custom value from single.php to another file via get
- variable not passed correctly to database using custom field
- WordPress Blocks, setAttributes not saving
- non-unique #_ajax_nonce id in browser console
- How do i call up default post title in custom posts
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Trying to get custom field data in a simple plugin
- Sort columns in the ‘Pages’ dashboard overview
- Why does this javascript search function in the WordPress Admin not work?
- 4 Unique Random Posts based on Custom Field Values
- Page template is missing fields or is invalid when I updating the template
- create a custom field that let me include other posts
- Check if value exists before saving
- Get meta value when the page is a blog archive
- Add Image With Changeable Link in Custom Field [closed]
- Populate a select box with data stored in the database?
- Create download page from post option link
- Add capability for editors to modify custom fields
- How to Pull Out Twitter Summary Data in other areas of my template?
- query specific posts according their custom fields, using sql SELECT
- Meta_query not filtering posts
- Custom fields driven site. I want to make a visual editor driven page template. How?
- list pages by custom_field?
- Get custom field from page, in a post?
- Make Custom Fields Public in JSON – API
- Advenced custom fields auto fill problem
- Order by a meta field in query loop
- Archive for custom fields?