Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Demokrit

    (@demokrit)

    Hi Fabio,

    thanks for the link. If I get you right, events manager is using standard category handling of WP. If so, it should be easy to reformat it via some custom code in my child theme. I’m no big friend of avoidable plugins ??

    Regards,
    Thomas

    Thread Starter Demokrit

    (@demokrit)

    Problem solved:

    ‘switch_theme’ was the wrong action. It’s fired on a theme unload event. Using ‘after_switch_theme’ instead results in correct image sizes including ‘medium_large’.

    Thread Starter Demokrit

    (@demokrit)

    Did you try a non-default permalink setting? I’m getting this error only with the default.

    Thread Starter Demokrit

    (@demokrit)

    Update: This problem seems to be related to permalink settings. It strikes on the default (https://www.mydomain.com/?p=123), but not on any of the alternatives.

    My problem seems to be related to:

    'base' => add_query_arg( 'cpage', '%#%'

    Thread Starter Demokrit

    (@demokrit)

    Hi bcworkz,

    thank you very much for the explanation. I wrote a custom navigation widget yesterday and can confirm the availability of the “class” within the custom code. But custom widgets never are a problem, since you can use any markup you like. So “class” is pretty useless unless integrated into the standard widgets. But even with a “class” feature, it would be no solid solution, since some widgets use unordered lists, others use table markup, which probably would need a different class.
    I could solve my problem by using “preg_replace” – don’t like this method, but it does it’s job for the 3-4 widgets I want to keep. The rest will be unregistered and substituted by sidebar code, which gives you much tighter control.

    Thanks again for your help,

    Thomas

    Forum: Hacks
    In reply to: Responsive image markup
    Thread Starter Demokrit

    (@demokrit)

    Thank you very much for you help. I’ve tried this hook yesterday, but problems occurred when I changed image alignment and/or size in the visual editor. The problem seems to be that I need a combination of both filters to add the image size class to the outer element in case of an existing caption.

    Today I analysed existing responsive websites. None of them is using in-text (floating) images at all. In Boostrap terms, everythink is ok as long as assets can be placed into BS columns. They fold nicely on small devices and everything is working right out of the box, without the need for custom styles.

    The solution might be, to use a custom gallery. Even for only one image. The first tests look very promising. I hope that I’ll find my final solution tomorrow.

    Forum: Hacks
    In reply to: Responsive image markup
    Thread Starter Demokrit

    (@demokrit)

    I have tried to enforce a “figure” wrapper for images with or without a caption:

    if (!function_exists('bootstrapped_img_caption_shortcode')) {
    
    	add_filter('img_caption_shortcode', 'bootstrapped_img_caption_shortcode', 10, 3);
    
    	function bootstrapped_img_caption_shortcode($empty, $attr, $content) {
    		$atts = shortcode_atts(array(
    			'id' => '',
    			'align' => 'alignnone', // alignnone, alignleft, alignright, aligncenter
    			'width' => '',
    			'caption' => '',
    			'class' => '',
    				), $attr, 'caption');
    
    		$atts['width'] = (int) $atts['width'];
    
    		if ($atts['width'] < 1)
    			return $content;
    
    		if (!empty($atts['id']))
    			$atts['id'] = 'id="' . esc_attr($atts['id']) . '" ';
    		switch ($atts['align']) {
    			case 'alignleft':
    				$bs_align_class = 'pull-left';
    				break;
    			case 'alignright':
    				$bs_align_class = 'pull-right';
    				break;
    			case 'aligncenter':
    				$bs_align_class = 'center-block';
    				break;
    			default:
    				$bs_align_class = '';
    		}
    
    		switch ($atts['width']) {
    			case '150':
    				$bs_wrapper_class = 'bs-thumbnail';
    				break;
    			case '300':
    				$bs_wrapper_class = 'bs-medium';
    				break;
    			case '640':
    				$bs_wrapper_class = 'bs-large';
    				break;
    			default:
    				$bs_wrapper_class = 'bs-block';
    		}
    
    		$class = trim('wp-caption thumbnail ' . $atts['align'] . ' ' . $atts['class'] . ' ' . $bs_align_class . ' ' . $bs_wrapper_class);
    
    		if (current_theme_supports('html5', 'caption')) {
    			if (empty($atts['caption'])) {
    				return '<figure ' . $atts['id'] . ' class="' . esc_attr($class) . '">'
    						. do_shortcode($content) . '</figure>';
    			} else {
    				return '<figure ' . $atts['id'] . ' class="' . esc_attr($class) . '">'
    						. do_shortcode($content) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
    			}
    		}
    	}
    }

    It seems, that this filter is not processed at all, if the image has no caption. As soon as I enter one, I get the expected result.

    The reason seems to be function “image_add_caption” in wp-admin/includes/media.php. It provides a filter, but this filter can never be executed if the image has no caption. This explains the current behavior.

    Image handling in WordPress seems to be very complicated.

Viewing 7 replies - 1 through 7 (of 7 total)