Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container-fluid">
  
  
  <div class="row">
    <div class="col-xs-12">
      <h1>Image name generator</h1>
    </div>
  </div>

  <div class="row">
    <div clas="col-xs-12">
      
      
      <div class="chunk segment">
        <label name="segment">Segment</label>
        <select>
          <option disabled selected>segment</option>
          <option>med</option>
          <option>phr</option>
          <option>cor</option>
        </select>
      </div>

      <div class="hyphen">
        &hyphen;
      </div>

      <div class="chunk type">
        <label>type</label>
        <select class="type-select">
          <option>ext</option>
          <option>com</option>
          <option>email</option>
          <option>soc</option>
          <option>int</option>
        </select>
      </div>

      <div class="hyphen">
        &hyphen;
      </div>

      <div class="chunk content">
        <label>content</label>
        <select class="empty" disabled>
        </select>
        <select class="ext" disabled>
          <option>N/A</option>
        </select>
        <select class="com">
          <option>ImageLarge</option>
          <option>FeaturedStat</option>
          <option>ImageCTASmall</option>
          <option>ImageCTALarge</option>
          <option>ImageCTAPrimary</option>
          <option>TextCarousel</option>
          <option>NowTrending</option>
          <option>ImageTextRotator</option>
          <option>CarouselContent</option>
          <option>ImageGallery</option>
          <option>ProductImage</option>
          <option>TabbedRotator</option>
          <option>Video</option>
          <option>Search</option>
          <option>Essential Insights</option>
          <option>Expert</option>
          <option>Category1Icon</option>
          <option>Category2Featured</option>
          <option>CategoryFeatured</option>
          <option>HomepageBanner</option>
          <option>CategoryMain</option>
        </select>
        <select class="email">
          <option>banner</option>
          <option>inline</option>
        </select>
        <select class="soc">
          <option>tw</option>
          <option>fb</option>
          <option>li</option>
        </select>
        <select class="int">
          <option>myCAH</option>
          <option>myHR</option>
          <option>Store</option>
        </select>
      </div>

      <div class="hyphen">
        &hyphen;
      </div>

      <div class="chunk descriptor">
        <label>descriptive name</label>
        <input placeholder="descriptive name">
      </div>

      <div class="hyphen">
        &hyphen;
      </div>

      <div class="chunk campaign">
        <label>campaign (if applicable)</label>
        <input placeholder="Campaign name here">
      </div>

      <div class="hyphen">
        &hyphen;
      </div>

      <div class="chunk dimensions">
        <label>image dimensions</label>
        <input class="width" placeholder="width"> x
        <input class="height" placeholder="height">
      </div>
      
      
    </div>
  </div>

  <div class="row">
    <div class="col-xs-12">
      <label class="result-label">Your file name</label>
      <input class="result">
    </div>
  </div>
  
</div>
              
            
!

CSS

              
                body
  font-family: Roboto
  font-size: 18px
  margin: 0
  padding: 20px
  color: #333333
  
h1
  font-weight: 300
  font-size: 2em
  letter-spacing: -0.0325em
  margin-left: -15px
  
label
  display: block
  font-size: .88em
  
select, input
  font-size: .88em
  font-weight: 300
  padding: 8px 4px
  width: 175px
  max-width: 100%
  border-radius: 4px
  background: #E7E7E7
  border: 0
  
select
  width: 100px

.content select
  width: 175px
  
.dimensions
  input
    width: 100px

  
.hyphen
  display: inline-block
  font-weight: 900
  font-size: 2em
  margin-top: 20px
  vertical-align: bottom
  
.chunk
  display: inline-block
  vertical-align: top
  select
    display: block
    text-align: center
    
.soc, .segment select
  text-transform: uppercase
  
.result
  width: 400px
  max-width: 100%
  margin-left: -15px
  color: #E41F35

.result-label
  margin-top: 2em
  margin-left: -15px
              
            
!

JS

              
                $(document).ready(function() {
  $('.content select').not('.empty').hide();

  function selectContent(contentType) {
    $('.content select').hide();
    $(contentType).show();
  }

  function pushResult() {
    var currentYear = (new Date()).getFullYear();
    var currentYear = currentYear.toString().substr(2, 3) + "-";
    var selected1 = $('.segment select').val();
    var selected1 = selected1.toUpperCase();
    var selected2 = $('.type-select').val();
    var selected3 = "-" + $('.content select[class="'+selected2+'"]').val() + "-";
    var selected4 = $(".descriptor input").val();
    var selected5 = "-" + $(".campaign input").val() + "-";
    if (selected5 == "--") {
      selected5 = "";
    }
    var imgWidth = $('.width').val() + "x";
    if (imgWidth == "x") {
      imgWidth = "";
    }
    var imgHeight = $('.height').val();
    console.log(selected3);
    if (selected3 == "-N/A-") {
      var selected3 = "-";
      console.log(selected3);
      var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
      $(".result").val(result);
    } else if (selected3 == "-inline-") {
      var selected3 = "-";
      console.log(selected3);
      var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
      $(".result").val(result);
    } else {
      var selected3 = "-" + $("." + selected2).val() + "-";
      if (selected3 == "-tw-" || selected3 == "-fb-" || selected3 == "-li-") {
        var selected3 = selected3.toUpperCase();
      }
      var result = selected1 + currentYear + selected2 + selected3 + selected4 + selected5 + imgWidth + imgHeight;
      $(".result").val(result);
    }
  }

  $('.type-select').change(function() {
    var selected = $('.type-select').val();
    selectContent("." + selected);
  });

  $('select').change(function() {pushResult();});
  $('input').change(function() {pushResult();});
  $(".result").click(function(){$(this).select();});

});
              
            
!
999px

Console