• Resolved pedromfm

    (@pedromfm)


    Hi,
    I’m building a website where I use PODS to store profiles for sustainability entrepreneurs.

    I’m using DIVI to build the template page for the profile page. Using the custom field feature of Divi I’m able to load, Video URLs for the Video Module, and text for text modules but the image module loads a URL with a number:

    <img src="https://2191" alt="" title="">

    However, using a shortcode, in a Divi code or text module

    [pods]{@foto_bigchanger._img}[/pods]

    works just fine.

    I’ve tried using the shortcode or just the magic tag – in the dynamic field of the image module – but it didn’t work.

    I guess it’s because the image field (upload field) on the POD isn’t outputting the image as the file URL/src.

    Is there a way to fix this? I’ve managed to work around it using some shortcodes and javascript but I would like to have a cleaner approach/solution.

    Thank you in advance.

    • This topic was modified 2 years, 4 months ago by pedromfm.
    • This topic was modified 2 years, 4 months ago by pedromfm.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Paul Clark

    (@pdclark)

    Under WP Admin > Pods > Settings, enable both “Watch WP Metadata calls” and “Override WP Metadata values”. Then, in a plugin, your theme’s functions.php, or a code snippets plugin, add this PHP:

    <?php
    
    add_filter(
    	'get_post_metadata',
    	function( $value, $object_id, $meta_key, $single, $meta_type ) {
    		if ( 'foto_bigchanger' === $meta_key ) {
    			return wp_get_attachment_image_url( (int) $value[0]['ID'], 'thumbnail' );
    		}
    		return $value;
    	},
    	20,
    	5
    );

    …where the name of the field is ‘foto_bigchanger’ and the image size is ‘thumbnail’.

    Thread Starter pedromfm

    (@pedromfm)

    Hi Paul. Thank you so much for the reply.

    One extra question – if I use your code, it means that every time I pick that field name on DIVI it will only display the thumbnail image (or the image size defined in that function).
    Is there a way it could use multiple image sizes?
    Or should I choose a bigger size so it fits most cases? – it’s not good for optimization.

    I’m asking this because sometimes I use the image as the background and it needs to be large.

    Again, thank you so much.

    Pedro

    • This reply was modified 2 years, 4 months ago by pedromfm.
    Plugin Support Paul Clark

    (@pdclark)

    You can use various template functions to change the size based on template context. For example, is_archive() and is_singular() to use one size for archives and another size for singular view.

    If both sizes exist in the same layout, it may be easiest to use two fields for this approach, or write a shortcode which takes the image size as an argument.

    Thread Starter pedromfm

    (@pedromfm)

    it may be easiest to use two fields for this approach

    Yes, it was an option that crossed my mind.

    Amazing suggestions.

    Thank you for your support, Paul.
    I’m closing this – your answers were more than helpful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘DIVI image module and PODs Image field’ is closed to new replies.