bildbeschreibung

Deutschsprachiger Support für CMS Made Simple
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: bildbeschreibung

Post by nicmare »

hmpf. ich weiß sehr wohl was jquery ist. das habe ich geschrieben. aber danke für deine mühen. Sind ja durchaus Leute hier umtriebig, die da noch nicht so bewandert sind.
mir erschließt sich eben nur nicht der grund weswegen es hier benötigt wird. Dieses Vorhaben kann man doch auch ohne JS realisieren?! denn leute die JS deaktiviert haben, scheinen ja dann die Bildunterschrift nicht sehen zu können. richtig?
Offenbar wird es benutzt um das DOM zu manipulieren. Derartige Manipulationen gehen auch grundsätzlich auf die Performance.
Es ist immer besser JS auf Minimum zu reduzieren. Versteh mich nicht falsch, ich bin ein großer Fan des Frameworks aber langsam zeichnet sich hier ab, nicht weiter nach den Sinn zu fragen ;-)
grüße
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

Jetzt verstehe ich vorauf du hinaus willst.
Wenn dies durch Smarty beim generieren der Seite erledigt werden sollte, müsstest du ein Plugin schreiben, dass den Inhalt vor der Ausgabe entsprechend modifiziert.

Der Content müsste dann entsprechend über diese Funktion geschlauft ausgegeben werden. Dies wäre sicher auch eine Möglichkeit.
[this message is written with 100% recycled bits]
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: bildbeschreibung

Post by nicmare »

ah, alles klar. danke. hab mich eh schon gefragt wieso es sowas nicht als plugin gibt. bzw sollte es out of the box dabei sein.
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

Möglicherweise kann Cyberman oder ein anderer die Frage am ehesten Beantworten.

Bei Systemen wie Wordpress wird (soweit zu mindest meine Beobachtung ohne den Code studiert zu haben) bei der Ausgabe des Contents von den Plugins Änderungen am Code vorgenommen. Eine ähnliche Möglichkeit könnte man denke ich auch für CMSms schaffen. Dies würde ganz neue Möglichkeiten ergeben.
[this message is written with 100% recycled bits]
cyberman

Re: bildbeschreibung

Post by cyberman »

nockenfell wrote: Möglicherweise kann Cyberman oder ein anderer die Frage am ehesten Beantworten.
Öhmmm, immer ich  ;D.
nicmare wrote: hab mich eh schon gefragt wieso es sowas nicht als plugin gibt. bzw sollte es out of the box dabei sein.
Warum muss es für jeden Hasenfurz ein Plugin geben, wenn es sich in Null komma nix mit Smarty machen lässt ... daher noch einmal der Link auf meine caption-Lösung  8)

http://forum.cmsmadesimple.org/index.ph ... #msg138019
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

cyberman wrote:
nockenfell wrote: Möglicherweise kann Cyberman oder ein anderer die Frage am ehesten Beantworten.
Öhmmm, immer ich  ;D.
Einer ist der Dumme  ;)

Code: Select all

{* sekretärin beginn *}
{content block='Bildunterschrift' wysiwyg='false' oneline='true' assign='caption'}
{if $caption != ''}
<div class="thumbnail">
<a href="{content_image block='Bild-groß' dir='images' urlonly='true'}" rel="lightbox" title="{$caption}">{content_image block='Bild' dir='images' alt=$caption}</a>
   <div class="caption">{$caption}</div>
</div>
{/if}
{* sekretärin ende *}
Wenn ich deine Funktion korrekt verstanden habe, machst du weitere Seiteninhalte mit den Namen "Bild", "Bild-gross" und "Bildunterschrift". Habe ich das richtig verstanden? Damit ermöglichst du zumindest nach meiner Rechnung nur 1 Bild pro Seite an einem definierten Ort. Ist das korrekt?

Im Vergleich dazu ist die Lösung mit dem JavaScript fähig mehrere Bilder einer Seite mit einer Bildunterschrift zu versehen. Damit das gleiche per PHP erledigt werden könnte, müsste der Content vor der Ausgabe modifiziert werden.

Die andere Möglichkeit wäre natürlich ein Tag {lightbox bild="xy" bildgross="yx" ausrichtung="links"}

Nur ist dieser nicht so wirklich Plug'n'Play für die Sekretärin.
[this message is written with 100% recycled bits]
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Die Bildbeschreibung ohne JavaScript erstellen

Post by nockenfell »

Die Idee die ImageCaption ohne JavaScript zu realisieren hat mich nicht in Ruhe gelassen. So habe ich vorhin ein wenig geforscht, bis ich für Wordpress ein Plugin gefunden habe, dass genau dies macht.

http://imagecaptioneasy.contentspring.com/

Die Lösung ist so noch nicht ganz ausgereift. Zumindest habe ich das Bild nicht auf Anhieb links oder rechts mit dem Rahmen plazieren können. Aber dies hier soll aus meiner Sicht nur eine Studie sein, wie es gehen könnte. Auch eine Lightbox Integration dürfte sich so machen lassen.

Um den Bildrahmen die im Content enthaltenen Bilder zu schreiben, muss folgende Datei erstellt werden:

Code: Select all

prefilter.imagecaption.php
erstellt werden.

In die Datei wird folgender Code geschrieben:

Code: Select all

<?php
function smarty_cms_prefilter_imagecaption($tpl_source, &$smarty)
{

   // return preg_replace('/<a href="#([A-Za-z0-9\\._-]+)">(.+)<\/a>/', "{anchor anchor='$1' text='$2'}test", $tpl_source);
   // preg_replace('/installation/', "Voll-Installations", $tpl_source);
   return imagecaptioneasy($tpl_source);
}

//Runs Image Caption Easy
function imagecaptioneasy($html) {

	$c = 0; //set count for each image found.
	
	if ( preg_match_all("/<img(.*?)>/is", $html, $img_matches) == true ) { //look through all img tags
		foreach ($img_matches[0] as $img_meta) {
			//Go through images.
			$image_code = $img_matches[0][$c];
			$image_code_escape = preg_quote($image_code, '/');
	
			$caption_text = ice_extractimageattribute($img_meta, "alt");
			if ( $caption_text != false ) {	
				//Dont add if no alt or ends with file name
				$test_alt = substr($caption_text, strlen($caption_text) - 4);
				if ( $caption_text == '' ) { $c++; continue; } //false
				if ( $caption_text == 'src=' ) { $c++; continue; } //false
				if ( $caption_text == 'align=' ) { $c++; continue; } //false
				if ( $test_alt == '.jpg' ) { $c++; continue; } //false
				if ( $test_alt == '.gif' ) { $c++; continue; } //false
				if ( $test_alt == '.png' ) { $c++; continue; } //false
				if ( $test_alt == '.JPG' ) { $c++; continue; } //false
				if ( $test_alt == '.GIF' ) { $c++; continue; } //false
				if ( $test_alt == '.PNG' ) { $c++; continue; } //false
			} else { 
				$c++; continue; //no title, false
			}
			
			//Image alignment.
			$align = ice_extractimageattribute($img_meta, "align");
			if ( $align === false ) {
				$align = "nowrap"; //set so can be no wrap and centerted.
			}
			//only float left/right/none is supported by css, so override to be nowrap.
			$alignOK = 0;
			if ( $align != 'left' ) { $alignOK = 1; }
			if ( $align != 'right' ) { $alignOK = 1; }
			if ( $align != 'nowrap' ) { $alignOK = 1; }
			if ( $alignOK === 0 ) { $align = "nowrap"; }
			
			//Image width, so know what size to make div.
			$width = ice_extractimageattribute($img_meta, "width");
			if ( $width === false ) {
				$src = ice_extractimageattribute($img_meta, "src");
				$width = ice_getimagewidth($src);
			}			
	
			//And alignment of top of entry or not.
			$top_of_page = ""; //default is not aligned at top.
			if ( $c === 0 ) { //first image
				$pos = strpos($html, "<img", 0);
				$test_ifattop = substr($html, 0, $pos);
				$test_ifattop_strip = strip_tags($test_ifattop);
				$test_ifattop_strip = trim($test_ifattop_strip);
				if ($test_ifattop_strip == '') {
					$top_of_page = "top_";
				}
			} //end if $c === 0 (is the first image)
				
			//If image is hyperlink wraped, extract and insert within the div not encapsulation it.
			$find_this_image_regex = "<a([^>]*?)>" . preg_quote($image_code, '/');
			if ( preg_match("/$find_this_image_regex/i", $html, $image_lined_res) ) {
				//remove hyperlink so can be placed within div latter.
				$find_to_replace = preg_quote($image_lined_res[0], '/') . "(.*?)\<\/a\>";
				$html = preg_replace("/$find_to_replace/", "$image_code", $html);
				$image_code = $image_lined_res[0] . "</a>";
			} //end if found image hyperlinked.

			//Now replace image code with new div-ed image code.
			$to_replace_with = "<div class=\"imagecaptioneasy imagecaptioneasy_" . $top_of_page.$align . "\" style=\"width:" . $width . "px;\">" . $image_code . "<br style=\"clear:both\" /><span>" . $caption_text . "</span></div>";
			$html = preg_replace("/$image_code_escape/", "$to_replace_with", $html);
			
		$c++;
		} //end foreach img
	} //end if found any img
	
	return $html; //completo return results...
	
} //end function (imagecaptioneasy)


//Function to extract elements from within the image code, like: alt, align, src etc.
function ice_extractimageattribute($image_text, $attribute_tag) {
	
	//Use this function instead of preg_match (REGEX) to make it run quicker.
	$posL = strpos($image_text, $attribute_tag);
	if ($posL === false) { return false; }
	$posL = $posL + strlen($attribute_tag) + 2;
	$imageattribute = substr($image_text, $posL);
	$posR = strpos($imageattribute, '"');
	$imageattribute = substr($imageattribute, 0, $posR);
	return $imageattribute;
	
} //end function (ice_extractimageattribute)


//If image does not have width in html uses this function.
function ice_getimagewidth($url) {
	
	if ( strpos($url, get_bloginfo('siteurl')) === false ) { //fix if not absolute url
		if ( substr($url, 0, 4) != 'http' ) {
			if ( substr($url, 0, 1) == '/' ) {
				$url = get_bloginfo('siteurl') . $url;
			} else {
				$url = get_bloginfo('siteurl') . '/'. $url;
			}
		}
	}
	
	error_reporting(E_ERROR);
	
	if (function_exists('gd_info')) {

		if (function_exists('curl_init')) {
			// Use cURL
			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL,$url); 
			curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
			curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,25); // set to zero for no timeout
			$result = curl_exec($ch);
			curl_close($ch); //close
		} else {
			// Use file_get_contents. Requires allow_url_fopen = On in php.ini, else try HTTP_Request.
			ini_set('default_socket', 25);
			$result = file_get_contents($url);
			if ($result == '') {
				echo "<strong><big>Image-Caption-Easy Plugin Error!</big></strong>\n";
				echo "<p>cURL and allow_url_fopen are both unavailable on your web server. Read image-caption-easy.php file for more information on using HTTP_Request.</p>\n";
				//If cURL and allow_url_fopen are both unavalable on your web server then try HTTP_Request or use a different web host.
				//For more information on using HTTP_Request: http://pear.php.net/package/HTTP_Request/
			}
		}
	
		if ( imagecreatefromstring($result) == true ) {
			$img = imagecreatefromstring($result);
		} else {
			return ""; 	//nada cant find images width OR could set 128 which is default thumbnail size if can find image or its width.
		}
				
		return imagesx($img); //got it...

	} else { //if no GD try GetImageSize.
	
		if (function_exists('getimagesize')) { 
			
			list ($img_width) = GetImageSize($url);
			return $img_width; //got it...
			
		} else { //nada, nada
			return "";	//nada cant find images width OR could set 128 which is default thumbnail size if can find image or its width.
		} //end if getimagesize
		
	} //end if not GD
	
} //end function (ice_getimagewidth)

?>
Danach muss noch das Stylesheet erstellt werden:

Code: Select all

/* 
Style Sheet code for Image Caption Easy Plugin for WordPress
Copy and Paste this code into your WordPress theme style sheet file (style.css) then upload to its location.
You can edit any of these to suit your needs.
*/
.imagecaptioneasy {
  padding: 5px;
  font-family: arial,helvetica,sans-serif;
  font-size: 10px;
  line-height: 1.15em;
  text-align: center;
  border: 1px solid #808080;
  background: #EAEAEA;
  color: #333;
}
.imagecaptioneasy img { border: 0px solid #fff; margin-bottom:5px; }
.imagecaptioneasy span { text-align: center; }
.imagecaptioneasy_top_left { margin: 0 11px 11px 0; float: left; }
.imagecaptioneasy_top_right { margin: 0 0 11px 11px; float: right; }
.imagecaptioneasy_top_nowrap { margin: 0 0 11px 0; float: none; }
.imagecaptioneasy_left { margin: 11px 11px 11px 0; float: left; }
.imagecaptioneasy_right { margin: 11px 0 11px 11px; float: right; }
.imagecaptioneasy_nowrap { margin: 11px 0 11px 0; float: none; }
Anschliessend läuft die Box.
[this message is written with 100% recycled bits]
cyberman

Re: bildbeschreibung

Post by cyberman »

nockenfell wrote: Wenn ich deine Funktion korrekt verstanden habe, machst du weitere Seiteninhalte mit den Namen "Bild", "Bild-gross" und "Bildunterschrift". Habe ich das richtig verstanden? Damit ermöglichst du zumindest nach meiner Rechnung nur 1 Bild pro Seite an einem definierten Ort. Ist das korrekt?
Das war die Aufgabenstellung in dem verlinkten Beitrag  ;D (wobei dass nur die Namen der Blöcke sind und nicht die der Bilder). Kannst die Blöcke ja beliebig oft einfügen. Und für eine andere Position ließe sich noch ein weiterer Block verwenden, in dem verschiedene Schlüsselwörter hinterlegt werden können, die dann mit verschiedenen Positionen verknüpft sind.
Die andere Möglichkeit wäre natürlich ein Tag {lightbox bild="xy" bildgross="yx" ausrichtung="links"}
So etwas in dieser Art ;)

http://dev.cmsmadesimple.org/projects/lightbox
Nur ist dieser nicht so wirklich Plug'n'Play für die Sekretärin.
Mann oh mann, können sich eure Kunden keine gute Sekretärin leisten? Oder was ist hier los?
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

cyberman wrote: Mann oh mann, können sich eure Kunden keine gute Sekretärin leisten? Oder was ist hier los?
Für die einen ist bereits der TinyMCE eine Herausforderung. Funktioniert nicht 100% gleich wie Word, ist also schwierig. So einfach ist das. Das Supporten ist einfacher, wenn man den Damen und auch Herren die Arbeit abnimmt.

Zudem habe ich es auch gerne "luxeriös"  ;D
[this message is written with 100% recycled bits]
cyberman

Re: bildbeschreibung

Post by cyberman »

Und warum hast du dann den prefilter-Post gelöscht :D?

Ich sehe (fast) alles!
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

Gelöscht? Wohl nicht von mir. Dann stell ich ihn halt wieder ein.
[this message is written with 100% recycled bits]
nicmare
Power Poster
Power Poster
Posts: 1150
Joined: Sat Aug 25, 2007 9:55 am

Re: bildbeschreibung

Post by nicmare »

nockenfell wrote: Zudem habe ich es auch gerne "luxeriös"  ;D
wir verstehen uns!  ;D
spike
Forum Members
Forum Members
Posts: 153
Joined: Thu Sep 25, 2008 5:02 pm

Re: bildbeschreibung

Post by spike »

Es geht auch mit CSS
http://www.inkwire.de/golf-across-northern-italy.html
z.B. Unterschrift: Golf Club Verona

CSS wie folgt:
/*The Image Caption Adventure*/
.imgcaptionright
{
float: right;
margin: 0 0 0 8px;
background-color: #fff;
padding: 0 0 0 8px;
border: 0px;
line-height: 200%;
}
div.imgcaptionright img
{ border: 0px;
padding: 0 0 4px 0;
}
/*End of the Image Caption Adventure*/
nockenfell
Power Poster
Power Poster
Posts: 751
Joined: Fri Sep 12, 2008 2:34 pm

Re: bildbeschreibung

Post by nockenfell »

spike wrote: Es geht auch mit CSS
http://www.inkwire.de/golf-across-northern-italy.html
z.B. Unterschrift: Golf Club Verona
Ist auch eine Möglichkeit. Wie fügst du das Stylesheet im TinyMCE ein?
[this message is written with 100% recycled bits]
spike
Forum Members
Forum Members
Posts: 153
Joined: Thu Sep 25, 2008 5:02 pm

Re: bildbeschreibung

Post by spike »

Extensions>TinyMCE>Advanced>
scroll down to Fenster
Additions to stylesheet:
CSS entered here will be added to the stylesheet read by TinyMCE after it recieves the CMSms styles

gruss - spike
Post Reply

Return to “German - Deutsch”