We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7087
    • 15 Posts

    Hi Again all,

    I have a template with a series of template variables within it. These variables are of type ’Image’ to allow users to select an image via the ’Insert’ button. In order to control the image size I am using CSS classes on the image tag. I know there are other methods like phpThumb etc but I could not get this to work and couldn’t get any help with it so I went for plan B.

    At least this method allows the user to insert the image (upload if necessary) and browse the images via the resource browser at the same time. Clearly, adding the image via the editor allows them to select sizes and ALT text etc but I have another TV for the ALT text in the manager for this purpose.

    The problem is that of course the template has the img tag within it configured like this.

    <img class="wide" src="[*Banner_Image*]" alt="[*Banner_Image_Description*]" title="[*Banner_Image_Description*]" />


    Now the problem is probably obvious, if the visitor does not enter an image path into the manager TV, the image tag ends up like this.

    <img class="wide" src="" alt="" title="" />


    This results in the browser showing a placeholder for the image with a ’red cross’ - not great.

    Not being a coding guru, I am wondering if there Is a way to get around this situation by for example hiding the img tag if the TV is empty so the browser simply does not display it?

    Hope this makes sense - look forward to any replies.

    Alan.
      • 24530
      • 100 Posts
      you could install PHX (http://wiki.modxcms.com/index.php/PHx) and insert something like [*Banner_Image:len:gt=`0`:then=`<img class="wide" src="[*Banner_Image*]" alt="[*Banner_Image_Description*]" title="[*Banner_Image_Description*]" />`*]
        my newest webpage [url=http://gitarren.zucali.at]Meisterwerkstatt f
        • 7087
        • 15 Posts
        Thanks raum,

        Great to know that there are people like you happy to answer posts.

        I am always one to say thank you - so thanks again.

        Alan.
          • 24530
          • 100 Posts
          Hi Alan!

          I am happy if this solution solved your problem. You could write a small snippet instead, but if you are no programmer phx is the easier solution.

          just one other thing, you wrote ...
          Quote from: denspad at Feb 22, 2008, 11:36 AM

          ... In order to control the image size I am using CSS classes on the image tag. I know there are other methods like phpThumb etc but I could not get this to work and couldn’t get any help with it so I went for plan B.
          I would clearly recommend to get phpthumb (or something similar) working, or upload the pictures in the desired size. If you just control the size by using css, the large picture is loaded (even if it is displayed smaller) and slows your page down.

          Good luck!
            my newest webpage [url=http://gitarren.zucali.at]Meisterwerkstatt f
            • 7455
            • 2,204 Posts
            or you could set a spacer/blank gif as standard image in the tv settings
              follow me on twitter: @dimmy01
              • 18253
              • 34 Posts
              This post seemed particularly interesting considering my image TV post was along the same lines of getting certain text in along with images. (alt and now in this case the Title attribute).

              I went on to research the need for a Title attribute with images since I thought it was something out of the ordinary but then happenned to look at my source and realize that I am overlooking my Title attributes on Menu Links (something I definetly believe all links should have) Question, does MODx already have a way of addressing the Title attribute or is something like this http://www.netconcepts.com/seo-title-tag-plugin/ available? Obviously the more automatic with customizing availability like the DynamicDescription snippet would be ideal.
                • 36592
                • 970 Posts
                Quote from: marco at Feb 25, 2008, 06:10 AM

                Question, does MODx already have a way of addressing the Title attribute or is something like this http://www.netconcepts.com/seo-title-tag-plugin/ available?
                You mean you just need the ’title’ attribute in Image output widget ?
                Then use the ’Attributes’ parameter in Image TV and set something like... title="[*TitleValue*]", where [*TitleValue*] is another text TV containing title value of this Image TV.